I am using this ajax function to post my form to a specific url .It is getting to the required url and processing but when it it return the result it is giving error.
I think the problem is with the data part of your ajax. serialize the form before send
$.ajax({
type: "POST",
cache: false,
url: $(this).attr('action'),
enctype: 'multipart/form-data',
data: $(this).serialize(),
success: function (data) {
alert("helo");
if (data.success == true) {
alert("The image is Uploaded");
}
},
error: function () {
alert(data.error);
}
});
Edit
$.ajax({
type: "POST",
cache: false,
url: $(this).attr('action'),
enctype: 'multipart/form-data',
data: new FormData(this),
processData: false,
contentType: false,
success: function (data) {
alert("helo");
if (data.success == true) {
alert("The image is Uploaded");
}
},
error: function () {
alert(data.error);
}
});