jQuery.post给出了错误

时间:2012-12-28 20:11:21

标签: html ajax jquery

我试图让这段代码工作,但它给了我一个错误。它似乎没有执行。

jQuery.post("getResults.php", {id:id} , function(data)
        {
            jQuery("select#kDate").removeAttr("disabled");
            jQuery("select#kDate").html(data);
        })
        .success(function() { alert("second success"); })
        .error(function() { alert("error"); })
        .complete(function() { alert("complete"); });
     });

任何帮助都将不胜感激。

2 个答案:

答案 0 :(得分:3)

错误功能有3个参数......

 error(jqXHR, textStatus, errorThrown)

试试这个:

error(function(xhr, status, detail) { alert("error ("+status+") : " + detail); });

文档在这里:http://api.jquery.com/jQuery.ajax/

答案 1 :(得分:0)

试试这个:你也可以看到here

var id = "some-value";
jQuery.post("getResults.php?id="+id, function(data) {
  jQuery("select#kDate").removeAttr("disabled");
  jQuery("select#kDate").html(data);
})
.success(function() { alert("second success"); })
.error(function() { alert("error"); })
.complete(function() { alert("complete"); });