When I submit below form the current page is refreshed and form parameters are appended to the end of the page URL. Why is this occuring ? I need to submit the form but the keep the form parameters hidden.
Thanks
<div class="ui-block-b"><button id="submit" type="submit">Submit</button></div>
$("#submit").click(function(){
var formData = $("#newPostForm").serialize();
$.ajax({
type: "POST",
url: "/mobile/newpost.php",
cache: false,
data: formData,
success: onSuccess
});
return false;
});
Get rid of the
type="submit"(which by the why should actually be<input type="submit">) and just make it a standard button if you don’t plan on actually submitting the form:An alternative method would be to set an
onsubmithandler on the form: