我正在使用summernote,我想将部分数据发布到控制器;这是数据的样子
<p>This is a sample test. </p>
下面是我正在使用的代码
var sHTML = $('#summernote').code();
$.ajax({
url: "Home/GetText",
data: sHTML,
type: 'POST',
cache: false,
contentType: false,
processData: false,
success: function (vaildText) {
// So something
},
error: function () {
alert('error');
// handle error
}
});
家庭控制器
[HttpPost]
[ValidateInput(false)]
public ActionResult GetText(string sHTML)
{
// doing something
return Json(vaildText);
}
但是家庭控制器上的 SHTML 给出了 NULL。我哪里错了?这是将 HTML 数据发布到控制器的正确方法吗?
Arun 请求的堆栈
Request URL:http://localhost:23680/Home/GetText
Request Method:POST
Status Code:200 OK
Request Headersview source
Accept:*/*
Accept-Encoding:gzip,deflate
Accept-Language:en-US,en;q=0.8
Connection:keep-alive
Content-Length:15
Content-Type:text/plain;charset=UTF-8
Cookie:__AntiXsrfToken=9d34feb94ea546abb4f50eb7251b4e25
Host:localhost:23680
Origin:http://localhost:23680
Referer:http://localhost:23680/
User-Agent:Mozilla/5.0 (Windows NT 6.2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.103 Safari/537.36
X-Requested-With:XMLHttpRequest
**Request Payload**
[object Object]