Php 为什么ajax请求被中止。。。。?
我正在向服务器发送ajax请求Php 为什么ajax请求被中止。。。。?,php,ajax,jquery,Php,Ajax,Jquery,我正在向服务器发送ajax请求 $.ajax({ type: "POST", data: checkin_push, url: api_url + 'file.php?token=' + last_token + '&date=' + dated, dataType: "json", timeout: 100000, // 100 seconds success: function(data) { // invoke syn
$.ajax({
type: "POST",
data: checkin_push,
url: api_url + 'file.php?token=' + last_token + '&date=' + dated,
dataType: "json",
timeout: 100000, // 100 seconds
success: function(data) {
// invoke sync
api_pending_sync = true;
// checkin back to home
$.mobile.changePage('#home', { reverse: true });
//api_sync_message
$('#sync-message').fadeIn(300).html('<div class="ui-body ui-body-e ui-corner-all" style="margin-bottom: 20px;" data-theme="d">Successfully checked in for ' + checkin_display_date() + '.</div>').fadeOut(5000);
},
complete: function(jqXHR, textStatus) {
$.mobile.hidePageLoadingMsg();
},
error: function() {
$('#checkin-status-message').fadeIn(300).html('<div class="ui-body ui-body-e ui-corner-all" style="margin-bottom: 20px; color: red;" data-theme="d">Unable to Check In, Please check your internet connection and try again.</div>').fadeOut(5000);
}
});
现在到底发生了什么。。如果在循环和电子邮件发送时控制进入,firebug将显示“已中止”状态,否则工作正常。。。
我做错了什么
提前感谢能否替换以下行:
error: function() {
以下是:
error: function(jqXHR, textStatus, errorThrown){
并检查textStatus
和errorhorn
的值,查看请求中止时的错误
希望这有帮助
$.ajax({
type: "POST",
data: checkin_push,
url: api_url + 'file.php?token=' + last_token + '&date=' + dated,
...
您正在发送GET和POST参数。因此,只需确保任何参数都不会得到null
在file.php中,
确保将标记
和日期
值作为$\u get
&checkin\u push
将参数值发送为$\u POST
或
获取所有发送的参数值,如
$\u REQUEST
有时发送电子邮件需要很长时间(而且您发送了很多),因此可能会超过php执行时间。没有json_out和escape之类的函数,除非您定义它们?您可以使用示例POST表单测试php文件,可以肯定的是,它起作用了fine@Ziarno它们是用户定义的。@AviC是的,我已经做到了,工作正常
$.ajax({
type: "POST",
data: checkin_push,
url: api_url + 'file.php?token=' + last_token + '&date=' + dated,
...