Here is my code:
$(document).ready(function(){
$("#mainbutton").click(function(){
$("#ajaxform").submit(function(e)
{
$.ajax(
{
action : "mainbutton",
url : "userctrl",
type: "post",
data : $(this).serializeArray(),
success:function(data, textStatus, jqXHR)
{
alert("success");
},
error: function(jqXHR, textStatus, errorThrown)
{
alert("error");
}
});
});
$("#ajaxform").submit(); //Submit the form
});
});
I try to set action in this post request but when I try to get it from the servlet it is null. Tried to change the request to get and again null. Also tried to put content-type: application/x-www-form-urlencoded but again no success. How to put action in this request. And it is appropriate to put action in post? If not should i make hidden field instead ? Also how I can use the parameters in function(data, textStatus, jqXHR)
action
attribute in.ajax()
– Marc B