2012-12-28 96 views
-1

我试图让这段代码正常工作,但它给了我一个错误。它似乎并没有执行。jQuery.post给出错误

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"); }); 
    }); 

任何帮助,将不胜感激。

+1

你并不需要2层成功的功能.. –

+0

我发现这里的代码,并添加它来尝试和工作发生了什么事情在我的代码。 – bobthemac

+0

通过在错误函数中记录传递的参数来查找有关错误的更多信息。另外:Firebug说什么? – madflow

回答

3

误差函数有3个参数....

error(jqXHR, textStatus, errorThrown) 

试试这个:

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

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

+0

这只是给我的错误:错误 – bobthemac

+0

@bobthemac - 尝试新版本 – Hogan

+0

我遇到这一点,得到错误未找到 – bobthemac

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"); });