If you are clicking the “submit” button in your form (which I am assuming); it will submit the form performing the default method GET
where no method is specified.
You need to ensure that you prevent the default submit action.
In your JavaScript; you are listening for a change
event on the entire form, instead you should bind to the submit button.
jQuery(document).ready(function($){
jQuery('#ticket').on('click', '#submit', function(event){
//prevent the default submit action of the form...
event.preventDefault();
//issue ajax request
jQuery.ajax({
type: "POST",
url : userlogin_object.ajaxurl,
data : {
'action': 'post_love_add_love',
'whatever': userlogin_object.the_issue_key
},
success: function(response) {
//process success response
alert('Got this from the server: ' + response);
jQuery("#form-messages2").html("TEST REQUEST");
}
});
});
});
If you really must listen for change
events; target the field that receives input, in your case it is one field only name="TKT_qty_new"
:
jQuery(document).ready(function($){
jQuery('#ticket').on('keyup click', 'input[name="submit"], input[name="TKT_qty_new"]', function(event){
//prevent the default submit action of the form...
event.preventDefault();
if ( event.type === 'click' && event.target.name !== 'submit' ) {
return false;
}
doAjaxRequest();
});
function doAjaxRequest() {
//issue ajax request
jQuery.ajax({
type: "POST",
url : userlogin_object.ajaxurl,
data : {
'action': 'post_love_add_love',
'whatever': userlogin_object.the_issue_key
},
success: function(response) {
//process success response
alert('Got this from the server: ' + response);
jQuery("#form-messages2").html("TEST REQUEST");
}
});
}
});