[英]JQuery Ajax post data not arriving
my Ajax post data is not arriving - any clues please. 我的Ajax帖子数据没有到达 - 请提供任何线索。
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 警报给了我一个像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 但是当我尝试用php回显basket-calc.php上的结果时,我得到一个“空”数组
basket-calc.php: 篮calc.php:
$test = $_POST;
print_r($test);
You can debug your request with firebug to make sure what is happening. 您可以使用firebug调试您的请求,以确保发生了什么。
Also try setting the post type to GET: 还可以尝试将帖子类型设置为GET:
type: "GET",
to see if it makes any difference. 看它是否有任何区别。
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: 另请注意以下几点:
hope this helps 希望这可以帮助
If your htaccess is stripping the .php from the , the POST gets converted to GET. 如果您的htaccess正在从中删除.php,则POST将转换为GET。 I think.
我认为。
Try and remove .php from your url. 尝试从您的网址中删除.php。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.