通过AJAX
发送的形式有效。如果不是JSON
格式,则执行success
。如果格式JSON
不是。我不知道问题是什么。
$('#registration').submit(function(event) {
var arrPhones= [],
arrUserInfo = [arrPhones],
arrForm = document.getElementById('registration');
event.preventDefault();
if(registFormValidation()) {
//...
}
var data = 'phones=' + JSON.stringify(arrUserInfo);
$.ajax({
type: 'POST',
url: 'regist.php',
dataType: 'JSON',
data: data,
error: function(error) { console.error(error); },
success: function( response ) {
jQuery('#update_form')[0].reset();
}
});
}
})
ERROR
{readyState: 4, getResponseHeader: ƒ, getAllResponseHeaders: ƒ, setRequestHeader: ƒ, overrideMimeType: ƒ, …}abort: ƒ (e)always: ƒ ()complete: ƒ ()done: ƒ ()error: ƒ ()fail: ƒ ()getAllResponseHeaders: ƒ ()getResponseHeader: ƒ (e)overrideMimeType: ƒ (e)pipe: ƒ ()progress: ƒ ()promise: ƒ (e)readyState: 4responseText: "bool(true)↵bool(true)↵string(16) "UPDAT ---> FALSE"↵
↵"setRequestHeader: ƒ (e,t)state: ƒ ()status: 200statusCode: ƒ (e)statusText: "OK"success: ƒ ()then: ƒ ()__proto__: Object
error @ (index):288
l @ jquery.min.js:4
fireWith @ jquery.min.js:4
k @ jquery.min.js:6
(anonymous) @ jquery.min.js:6
load (async)
send @ jquery.min.js:6
ajax @ jquery.min.js:6
(anonymous) @ (index):283
dispatch @ jquery.min.js:5
y.handle @ jquery.min.js:5