I just upgraded to JQuery 1.5.2 from 1.4 and my PostForm is not working now . It does post to page but even though there is no error it says there is error.
function TestPostForm(){
$.ajax({
type: "POST",
url: "process.jsp",
data: 'operation=Test&ui=TestUser',
dataType: "application/x-www-form-urlencoded",
async: false,
success: function(response) {
alert('Success');
return response;
},
error: function(xhr, ajaxOptions, thrownError) {
alert("There was an error : " + xhr.status);
}
});
}
Java Code : process.jsp
if (operation.equals("Test")) {
String ui = request.getParameter("ui");
out.println("Ok" + ui);
}
Your problem is with
dataType, what you should have defined wascontentTypeString:dataTypedefines what type of data you expect your script to return (xml, json, script or html) whilecontentTypepasses the type of content you are sending in the request.You can read more about these options on the jQuery API: http://api.jquery.com/jQuery.ajax/