这是我的jQuery代码 ,接下来是我的json函数来处理这个名为InsertMatlabJson
的jQuery代码。如何将HTML内容发送到ASP.NET MVC JSON函数?
问题是没有文本进入到.NET json函数中。 。 。
function insert() {
var url = '<%=Url.Content("~/") %>' + "Matlab/InsertMatlabJson";
var text = document.getElementById('MainContent_FreeTextBox1').value
$.ajax({
url: url,
type: 'GET',
data: { text: text},
contentType: 'application/json; charset=utf-8',
success: function (response) {
//your success code
alert("opk");
},
error: function() {
//your error code
alert("no");
}
});
}
public JsonResult InsertMatlabJson(string text)
{
}
你想通过发送HTML查询并在函数上接收它作为文本变量? –
是你的问题,在ASP.NET MVC中,你没有收到任何文本参数? – BadFeelingAboutThis
尝试更改:类型:'GET'键入:'POST' –