i am try开发者_运维技巧ing to pass in a filename as a requestparameter into a controller, but it returns with an invalid request?
$(document).ready(function (event) {
$('#btnTask').click(function () {
$.ajax({
url: "/Home/Sometask/",
data: "c:\\somefile.txt",
async: false,
success: function (data) { alert(data); }
});
event.preventDefault;
});
});
public string Sometask(string id)
{
return "ready";
}
Use data: { filename: "c:\\somefile.txt" }
You have to give a variable name for the post data so your controller know how to map the value.
精彩评论