我想將包含html標籤的參數作爲其值傳遞給webmethod。但它似乎不工作,我只是得到錯誤。有可能這樣做。你能建議任何其他方式來做同樣的事情嗎?如何將html標籤傳遞給webmethod?
htmlContent = htmlContent + document.getElementById("divFollowsTestDiv").innerHTML;
//這裏即時存儲標籤和下面的方法調用webmethod。
function StoreSessionForHtml(htmlContent) {
var requesthtmlContentParameter = '{' +
'htmlContent:"' + htmlContent + '"}';
$.ajax({
type: "POST",
url: "Webtop.aspx/HTMLTableContent",
data: requesthtmlContentParameter,
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(msg) {
alert("Success", msg.d);
}, //Event that'll be fired on Success
error: function() {
alert("Try Again");
} //Event that'll be fired on Error
});
}
您是否嘗試過的HTML編碼嗎? – bevacqua 2011-05-27 04:42:55
您的意思是轉換所有那些< >符號?沒有 – NewBie 2011-05-27 04:47:14