【发布时间】:2016-12-07 21:18:11
【问题描述】:
我正在尝试使用 ajax 传递数据并在我的 mvc 项目中触发控制器
这是我的控制器
public class FileController : Controller
{
[HttpPost]
public ActionResult Index(string data)
{
return View();
}
}
这是js
$('#getmessage').on('click', function () {
var text = '';
$('#discussion>li').each(function () {
text += $(this).text();
text += '\n'
})
console.log(text)
$.ajax({
url: 'http://localhost:22828/File/Index',
type: 'POST',
data: text,
success: function (result) {
console.log("data sended");
}
})
})
我需要将文本传递给控制器,但在我的控制器中我得到NULL
有人可以说明一下吗?
提前致谢
【问题讨论】:
标签: jquery ajax asp.net-mvc