Joydip Panchal Javascript Tutorial
Send form data via ajax jQuery :

Do you want to submit form via ajax? Do you want to upload files via ajax? Refer following code :

var formObj = $("#your-form-id";
var formData = new FormData(formObj[0]);
$.ajax({
url: formObj.attr("action", //server script to process data
type: formObj.attr("method", // method for sending data
dataType: 'json', // return type of response data from above url
data: formData,
cache: false,
success: function (response)
{
// this will call after request successfully done
},
error: function () {
// this will call if request has any error
},
contentType: false,
processData: false
});
Like · Comment ·
Admin likes this

Joydip Panchal

Add event.preventDefault(); return false; this after ajax call, this will stop actual redirection of page
Like · 1 ·

Admin

Good
Like ·
Download Android App