I'm trying to catch Ajax timeout error with jQuery 1.4.2, but none of tutorial I found work. In Firebug, when timeout error fires. I see:
uncaught exception: [object Object]
.
Please help me handle Ajax timeout. Here's my JS code:
$.ajax({
type:"POST",
url:"/data/add/",
data:
{
"date":$("input#date").val();
},
dataType:"json",
timeout:2000,
success: function(response) {
},
error: function () {
alert('Server error');
}
});
I'm trying to catch Ajax timeout error with jQuery 1.4.2, but none of tutorial I found work. In Firebug, when timeout error fires. I see:
uncaught exception: [object Object]
.
Please help me handle Ajax timeout. Here's my JS code:
$.ajax({
type:"POST",
url:"/data/add/",
data:
{
"date":$("input#date").val();
},
dataType:"json",
timeout:2000,
success: function(response) {
},
error: function () {
alert('Server error');
}
});
Share
Improve this question
edited Jul 12, 2021 at 18:41
Brian Tompsett - 汤莱恩
5,89372 gold badges61 silver badges133 bronze badges
asked Aug 22, 2010 at 2:43
andymcgregorandymcgregor
1,0152 gold badges14 silver badges29 bronze badges
1
- You have an errant semi-colon in your data option. See my answer below. – David Hoerster Commented Aug 22, 2010 at 3:35
2 Answers
Reset to default 5I tested this out, and if you remove the ;
from your $("input#date").val()
statement, it should work.
$.ajax({
type:"POST",
url:"/data/add/",
data:
{
"date":$("input#date").val()
},
dataType:"json",
timeout:2000,
success: function(response) {
},
error: function () {
alert('Server error');
}
});
something went wrong again, and i got googled this f*****g bug http://dev.jquery./ticket/6173 ! here is the spike:
success: function(response, textStatus, xhr) {
if (!xhr.status) {
alert("ERROR!!!!");
}
else {
// elided
}
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744888339a4599252.html
评论列表(0条)