$(this).ajaxSubmit({
url: 'url',
dataType: 'json',
cache: 'false',
beforeSend: function(){
alert('before')
},
success: function(data){
alert('success')
},
error: function(data) {
console.log(data);
},
});
始终通过以下方式访问错误案例:
Object {aborted: 0, responseText: "{"success":false,"error_message":"<p>The
Title fie…:"The Introduction text field is required."}}</p>", responseXML: document, status: 0, statusText: "n/a"…}abort: function (status) {aborted: 0error: SyntaxError: Unexpected token <getAllResponseHeaders: function () {}getResponseHeader: function (header){responseText: "{"success":false,"error_message":"<p>The Title field is required.<\/p>\n</p><p>The Introduction text field is required.<\/p>\n","error_fields":{"title":"The Title field is required.","intro_text":"The Introduction text field is required."}}</p>"responseXML: nullsetRequestHeader: function () {}status: 0statusText: "n/a"__proto__: Object
和控制器响应
{"success":false,"error_message":"<p>The Title field is required.<\/p>\n<p>The Introduction text field is required.<\/p>\n","error_fields":{"title":"The Title field is required.","intro_text":"The Introduction text field is required."}}
答案 0 :(得分:0)
尝试使用此代码。
$(this).ajaxSubmit({ type: "POST", // Enter Request type GET/POST url: 'action.php', // Enter your ajax file URL here, dataType: 'json', // If you are using dataType JSON then in php file use die( json_encode($resultArray) ); cache: 'false', data: {_keyName: "abcd"}, // Put your values here beforeSend: function(){ alert('before') }, success: function(data){ alert('success') }, error: function(data) { console.log(data); } });
告诉我其他什么
答案 1 :(得分:0)
检查服务器端的代码,因为客户端没有错误
尝试以下步骤:
1-打印任何透明的东西,例如: 回声“测试”
2-如果您没有错误,请检查您的回复数据,因为, 我猜你错过了逗号或以错误的方式添加了html元素
答案 2 :(得分:0)
$(this).ajaxSubmit({
type: "POST", // Enter Request type GET/POST
url: 'action.php', // Enter your ajax file URL here,
dataType: 'json', // If you are using dataType JSON then in php file use die( json_encode($resultArray) );
cache: 'false',
data: {_keyName: "abcd"}, // Put your values here
beforeSend: function(){
alert('before')
},
success: function(data){
alert('success')
},
error: function(data) {
console.log(data);
}
});