我正在向服务器发送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 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);
}
});以下是file.php的相关代码
=========rest code -=================
#------------------- send alert to life lines (send alerts) -------------------
$query = query("SELECT email, phone, sms_carrier FROM table WHERE account_id = ".escape($account_id));
if ((mysqli_num_rows($query) > 0) and $send_alert)
{
while ($l = mysqli_fetch_assoc($lifelines))
{
// send mail
/* this function is returning value of mail() function*/
send_alert_email($userEmail, $sms_email, 'alert-2');
}
}
#-------------------------------(/alerts)--------------------------------------
$return = array('answers' => $answers); //, 'transact' => $checkin_transact);
}
json_out($return);
?>现在到底发生了什么..。如果控制进入而循环和电子邮件正在发送,firebug显示状态为'aborted‘,否则它工作正常...我做错了什么..。
提前感谢
发布于 2013-05-24 19:54:21
您可以替换下面的行吗:
error: function() {具有以下功能:
error: function(jqXHR, textStatus, errorThrown){并检查textStatus和errorThrown的值,看看请求中止时的错误是什么。
希望这能有所帮助。
发布于 2013-05-24 20:18:08
$.ajax({
type: "POST",
data: checkin_push,
url: api_url + 'file.php?token=' + last_token + '&date=' + dated,
...您正在发送GET和POST参数。所以,我只想确认一下,你没有得到任何参数的null。
file.php中的,
确保以$_GET格式获取token和date值
以$_POST格式发送参数值(& checkin_push )
或
获取所有发送的参数值作为$_REQUEST
https://stackoverflow.com/questions/16734159
复制相似问题