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
});
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
});
Admin likes this
Joydip Panchal
Admin