I know this sounds silly but I am stuck as what ever value that is returned using the controller as Json, i.e 1, 0, true or false and on checking the ajax file upload success part data it contains only "Success" as value no matter what the return value of the controller is.
Here, I am using Ajax file upload as I am uploading a file from the client side.
Controller code:
public ActionResult ImportExcelData(HttpPostedFileBase UploadExcel)
{
try
{
var Data = Repository.ImportData(filePath, OrgID);
return Json(true, JsonRequestBehavior.AllowGet);
}
catch(Exception)
{
return Json("false", JsonRequestBehavior.AllowGet);
}
}
View code:
$.ajaxFileUpload({
url: '@Url.Action("ImportData", "Lead")',
secureuri: false,
type: 'POST',
datatype: 'JSON',
contentType: "application/json; charset=utf-8",
cache: false,
fileElementId: "Upload",
success: function (data) {
//data contains only success as value.
}
});
Can anybody help me out, cheers.