-2

I have a shopping cart page. I am using ajax function to add products to cart. so my page will not refresh. But after added to cart , i need to display you have n number of items in your cat. It is working fine if i refresh my page. i need to do that without refrsh my page i have write this

<script>
$(document).ready(function(){
  $("#addtocartbutton").click(function(){


   $("#cartdiv").refresh();


  });
});
</script>

but not refrshing that div. please helm me friends

Ammu
  • 138
  • 3
  • 12

2 Answers2

0

Cool, so the ideal way to use http://api.jquery.com/jQuery.ajax/ is:

Within sucess function you update your page or div.

Also for the load issue look in here * Refresh/reload the content in Div using jquery/ajax

Hope this gives you enough to rectify the ajax :) and reload the information in div

Sample code

// Assign handlers immediately after making the request,
// and remember the jqXHR object for this request
var jqxhr = $.ajax( "example.php" )
  .done(function() {
    alert( "success" );
  })
  .fail(function() {
    alert( "error" );
  })
  .always(function() {
    alert( "complete" );
  });
Community
  • 1
  • 1
Tats_innit
  • 33,991
  • 10
  • 71
  • 77
0

Use load() like,

$("#cartdiv").load('page.php');
Rohan Kumar
  • 40,431
  • 11
  • 76
  • 106