I have the below ajax request
var data = { ID: "data" };
$.ajax({
type: "POST",
cache: false,
url: url,
data:data,
processData: false,
contentType: false,
success: function (result) {},
error: function (response) {}
});
and I have this MVC controller
[HttpPost]
public ActionResult Test(string ID)
{
return Json(new { isSuccess = true }, JsonRequestBehavior.AllowGet);
}
The issue is that in the controller the ID is coming out null. If I use formdata then it works. I cannot use formdata because it does not work with IE9. I have something working with IFrames for it but it is too complicated and kind of a hack.
var fd = new FormData();
fd.append("ID", "data");
Can someone please tell me how to make it work. And also how can we make it work to transfer files to the server without using formdata.
Try to use
$.post(url, data)
.done(successClbck)
.fail(errorClbck)
instead of $.ajax
. It's work well for all data objects but not for files
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.