store:function(){
form.on('submit(*)', function(data){
var url = $(data.elem).data('url');
if(url == undefined || url == '')
{
layer.msg('請設定請求URL', {icon: 5,anim:6,offset: '100px'});
return false;
}
var ajax_lod = layer.load(1);
$.ajax({
headers: {
'X-CSRF-TOKEN': admin.CRSFTOKEN
},
type:"POST",
url:url,
data:data.field,
dataType: "json",
success: function(data){
layer.close(ajax_lod);
if(data.code == 200)
{
layer.msg(data.data.message,{icon: 1,offset: '100px'})
}
},
error:function(XMLHttpRequest, textStatus, errorThrow){
layer.close(ajax_lod);
var ret_code = XMLHttpRequest.status;
var ret_json = XMLHttpRequest.responseJSON;
if(ret_code == 422 && ret_json.errors !== undefined){
for (var i = ret_json.errors.password.length - 1; i >= 0; i--) {
layer.msg(ret_json.errors.password[i],{icon:5,anim:6,offset: '100px'});
break;
}
}else if(ret_code == 422){
layer.msg(ret_json.message,{icon: 5,anim:6,offset: '100px'})
}else if(textStatus == 'error') {
console.log(ret_json.message)
layer.msg('請求失敗,系統異常:'+ret_json.message,{icon: 5,anim:6,offset: '100px'})
}
}
});
return false;
});
}
本作品採用《CC 協議》,轉載必須註明作者和本文連結