How to retrieve data when post using AJAX my function is that
jQuery("#wp_pass_reset").submit(function() {
var url = document.getElementById('imgurl').innerHTML;
var url2 = document.getElementById('adminurl').innerHTML;
jQuery('#result').html('<span class="loading"><img src="' + url + '/img/load.gif" /></span>').fadeIn();
var input_data = jQuery('#wp_pass_reset').serialize();
jQuery.ajax({
type: "POST",
url: url2 + 'admin-ajax.php',
data: {
action: 'resetpass_process',
value: input_data,
},
success: function(msg){
jQuery('.loading').remove();
jQuery('<div>').html(msg).appendTo('div#result').hide().fadeIn('slow');
}
});
return false;
});
This is the form:
<form class="user_form" id="wp_pass_reset" action="" method="post" name="wp_pass_reset">
<h1>
Enter Your Email or Username
</h1>
<input type="text" class="text" name="user_input" value=""><br>
<input type="hidden" name="action" value="tg_pwd_reset">
<a class="close">X</a>
<input type="hidden" name="tg_pwd_nonce" value="'.wp_create_nonce(">
<input type="submit" id="submitbtn" class="reset_password btn" name="submit" value="Reset Password">
</form>
When I retrieve data using $_POST['value']
all of my data show but when I use $_POST['user_input']
an error happens.
What can I do?
Here, you are submitting form by ajax then you have to pass it in
data
like,Add user_input from your form field name to data object: