ajax updating sql then load to bring it back
Hi, I'm having trouble getting this to work...
I setup a jquery ajax request to update my sql database... (add a product to shopping cart) then after it completes i want to use .load to re-load the shoppingcart (the cart is currently loaded with php include - so it is it's own seperate .php file)
The problem is that when it reloads it doesn't have the "current version" If i refresh the page it's fine..
example -
<script type="text/javascript">
$(function() {
$("#addtocart").click(function() {
$.ajax({
url: "addtocart.php",
data: **form data here**,
complete: function() { $("#cart").load("cart.php"); }
});
});
});
</script>
<div id="cart">
<? include("cart.php"); ?>
</div>
<button id="addtocart">Add to cart</button>
--
i have also tried to put a variable in front from the $.ajax and then use $("#cart").ajaxComplete(function() { $(this).load("cart.php"); } }); but yet still no luck.
Does anyone know how to make ajax load a page AFTER the mysql update has been done then display it?! I used to do this all the time before i started using jquery. when readyState was = 4 { load page code here } it would always work.
anyways any help would be awesome! thanks!