我有一個用於輸入內容的textarea(tinymce)表單。當我執行一個Ajax請求,我得到了錯誤:如何通過ajax請求發送html內容?
A potentially dangerous Request.Form value was detected from the client
然後我試着像
html.encodeURIComponent()
或escape()
但錯誤仍在這裏
HTML:
<form id="editForm" action="" method="post">
<input type="text" id="title" name="title" />
<textarea id="content" name="content"></textarea>
<input type="button" id="submit" onclick="Submit();" />
</form>
腳本(我用jQuery)
function Submit(){
$.ajax({
url: 'ajax.aspx?type=addcontent&' + $('#editForm').serialize() + '&rnd=' + Math.random(),
success: function(data) {
alert('OK');
}
});
}
只要按下提交按鈕,就會出現錯誤。沒有ajax請求。我已經嘗試將ValidateRequest="false"
添加到aspx頁面,但問題仍然存在。
任何幫助表示讚賞!
我想這太讓我一直在努力,在HTML內容進行編碼,但仍然一無所獲~~ – ByulTaeng 2010-09-18 08:41:01
你不需要任何編碼。如果您使用'data'散列來發送參數,jQuery將負責編碼。 – 2010-09-18 08:42:59
你能否給我一個例子或鏈接到tut?非常感謝! – ByulTaeng 2010-09-18 08:51:38