简体   繁体   中英

Data not being sent to PHP from jQuery AJAX

Following ajax code is not sending the data to PHP. Is there anything wrong with this code?

data = {"email":email,"reset_key":getUrlVars()["key"]}; console.log(data); console.log is showing {email: "test@gmail.com", reset_key: "6d8fd92a9c49bf139f945350c7c39092"}

// alert($('#reset_key').val());
$.ajax({
  url: '<?=$server?>/inc/ajax.php?q=check_reset_expiry',
  data: data,
  type: 'post',
  dataType: 'json',
  processData: false,
  contentType: false,
})
.done(function(res){
  console.log(res);
  if (res.hasError) {
    $("#errMsgReset").show(100);
    $("#errMsgReset").html(res.errorMsg);
    $('#btn-reset').attr('disabled', true);
  }
})
.fail(function(err){
  console.log(err);
  $('#errMsgReset').show(100);
  $("#errMsgReset").html("Password reset failed. Please try again.");
});

Maybe this could help you:

.done(function(data){
    console.log(data);
})

You get back a json string no html. So create HTML-Code and pass it to the html() function.
Error should be in fail

.fail(function(err){
    console.log(err);
});

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