AJAX表单有效,但不能成功

时间:2018-04-18 10:45:54

标签: javascript json

通过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

0 个答案:

没有答案