简体   繁体   中英

Success event in jquery ajax is not working

I'm trying to get success event but it works only for error: event Don't know what is error.

$(document).ready(function() {
  $.ajax({
    type: "POST",
    url: "http://localhost/Register/intl-tel-input-master/next.php",
    data: {
      arguments: [fname, lname, email, Numb, pass, confirm]
    },
    dataType: 'JSON',
    complete: function(data) {
      if (('error' in data)) {
        this_form.find('.error-message').slideDown();
      } else {
        alert(data);
        this_form.find('.sent-message').slideDown();
      }
    }
  });
  // return false;
});

Try to check response using done/fail:

 $(document).ready(function() {
   $.ajax({
      type: "POST",
      url: "http://localhost/Register/intl-tel-input-master/next.php",
      data: {
        arguments: [fname, lname, email, Numb, pass, confirm]
      },
      dataType: 'JSON',
      })
      .done((res) => {
        console.log(res)
      })
     .fail((res) => {
        console.log(res)
      })
    });

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM