【发布时间】:2017-12-15 07:58:31
【问题描述】:
我的项目有问题。当我提交表单时,Ajax 仅在 Developers Tool Mozilla 中请求 1,但突然在服务器中好像请求调用了两次(我在代码中添加日志进行检查)。 有时这个问题不会发生,但会发生更多。 是否可能与稳定的互联网连接有关?
这是我的 ajax。
$('#GIForm').submit(function(e) {
e.preventDefault();
}).validate({
submitHandler:function(form){
if(countSave == 0){
$.ajax({
url:'/new',
method:'post',
async: false,
data: {
date : $('#GIDate').val(),
notes : $('#GINotes').val(),
mswarehouse_id : $('#GISourceWarehouse').val(),
mstransactiontype_id : $('#GIType').val(),
dest_msoutlet_id : $('#GIOutlet').val(),
msvendor_id : $('#GIVendor').val(),
detail : detail
},
success: function(response){
$('#pleaseWaitDialog').modal('hide');
if(response.status=='success'){
var message = 'Document ' + response.description.document + ' has been saved!';
showAlert('',message,'success',function(e){
window.location.replace(laroute.route('admin.goods_issue.index'));
});
}else{
showAlert('',response.description,'error');
$('#addGIbtn').prop('disabled',false);
countSave = 0;
}
}, error:function(xhr,text, status){
$('#pleaseWaitDialog').modal('hide');
$('#addGIbtn').prop('disabled',false);
countSave = 0;
if(xhr.status==422){
showAlert('',xhr.responseJSON.join('\n'),'error');
}
}
});
return false;
}
}
});
这是来自 Dev 的图片。工具 Mozilla。我模糊了域。 我不知道为什么颜色状态响应只有灰色,并且响应已经返回状态成功。 这个问题使我的数据库插入两次。 这是我的Mozilla的截图。 Response from Network Dev Tools Mozilla
请帮忙,我不知道了
【问题讨论】:
-
@ZaheerUlHassan :他提到他的响应状态是成功但奇怪的是,他的请求/响应没有任何状态代码,就像它仍在等待中一样
标签: javascript jquery ajax laravel laravel-5