views:

44

answers:

2

Hi folks, my Ajax post data is not arriving - any clues please.

The data is a serilaized form that "alerts" correctly with all the data using this

 $(document).ready(function() {
 var serial = $('#frm_basket').serialize();
 alert(serial);
 $.ajax({
 url: "basket-calc.php",
 type: "post",
 data: serial,
 success: function(){
  ("#basketTotal").load('basket-calc.php');
  }
  });
});

The alert gives me a string like product=p1&qty=1&product=p2&qty=2

But when I try to php echo out the results on basket-calc.php I get an "empty" array

basket-calc.php:

    $test = $_POST;
print_r($test);
+3  A: 

You can debug your request with firebug to make sure what is happening.

alt text

Also try setting the post type to GET:

type: "GET",

to see if it makes any difference.

Sarfraz
A: 

try:


$(document).ready(function() {
 var serial = $('#frm_basket').serialize();
 alert(serial);
 $.ajax({
 url: "basket-calc.php",
 type: "post",
 data: serial,
 success: function(result){
  ("#basketTotal").html(result);
  }
  });
});

Also note following points:

  1. make sure basket-calc.php is not returning 404
  2. try sending blank data and echo your response
  3. once you get sample string from server, just attach the real data

hope this helps

lakhlaniprashant.blogspot.com