Friday 15 February 2013

jquery - not able to submit the ajax form after replaceWith -



jquery - not able to submit the ajax form after replaceWith -

i trying larn create shopping cart cart jquery

$(document).ready(function() { $(".ajaxform").submit(function(e) { $.ajax({ url: "cart.php", type: "post", data: $(this).serialize(), success: function(responsedata, textstatus, jqxhr) { $(".cartrow").append("<div class=\"cart-row\">" + responsedata + "</div>"); }, error: function(responsedata, textstatus, jqxhr) { //if fails alert("fail"); } }); e.preventdefault(); //stop default action e.unbind(); //unbind. stop multiple form submit. }); });

this html form using submit form

<div class="product-tab" id="disp"> <!-- bootstrap - min --> <div class="product-detail fade active in " id="all" > <!-- bootstrap - min --> <form class="ajaxform" method="post" ><h4><input type="hidden" name="pid[]" value="1001"> <input type="hidden" name="unit" value="10">onion(<del>&#2352;</del> 120)<hr></hr></h4>10<br><h6> <label class="group"><input type="number" maxlength="2" name="quantity"/></label><h6> <input type="submit" value="add cart" class="btn"></input><hr></hr></form> </div> </div>

when submit form works fine , able add together items cart when seek filter items using code below add together cart button wont phone call jquery adding items cart

$(document).ready(function() { $('input[type="radio"]').on('change', function() { var selectedprice = new array(); $('input[name="price"]:checked').each(function() { selectedprice.push(this.value); }); var brand = new array(); $('input[name="filter[]"]:checked').each(function() { brand.push(this.value); }); $.ajax({ url: 'no_product_filter.php', type: 'post', data: { selectedprice: selectedprice, brand: brand }, success: function(response) { $("#disp").replacewith("<div class=\"product-tab\" id=\"disp\">" + response + "</div>"); }, error: function(response) { alert("fail" + response); } }); }); });

is there should no when using jquery replacewith .the response mentioned above php has same construction html barring items removed using filter . please have look

jquery html

No comments:

Post a Comment