Getting error "javaScript runtime error: Invalid calling object"

Posted by Krishnasamy2008 under ASP.NET MVC on 6/20/2014 | Points: 10 | Views : 2096 | Status : [Member] | Replies : 1
Hi Friends,

I'm unable to figure out the issue.Please find the below code.

function SaveUploadData() {
debugger;
// var formData = new FormData();
// formData.append("coverFile", $("#fileUpload").file);

alert("step1");
//var file = $('#fileUpload').prop("files")[0];

$.ajax({
type: 'POST',
url: '@Url.Action("UploadDataToServer")',
dataType: 'json',
contentType: "multipart/form-data",
data: { Postedfile: $('#fileUpload').prop("files")[0] },
//data: formData,
success: function (empList) {
//debugger;
//alert(empList);
alert('success');
},
error: function (ex) {
alert('Failed to retrieve records.' + ex);
}
});
return false;

}

[HttpPost]
public ActionResult UploadDataToServer(HttpPostedFileBase fb)
{
HttpPostedFileBase myFile = Request.Files["fileUpload"];
}




Thanks,
Krishna.K




Responses

Posted by: Sheonarayan on: 6/22/2014 [Administrator] HonoraryPlatinum | Points: 25

Up
0
Down
See the source code of the page and check if jQuery file has been referenced, if not add jQuery bundle from Budlge.config and it should work.

Thanks

Regards,
Sheo Narayan
http://www.dotnetfunda.com

Krishnasamy2008, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response