如何使用jquery的$post提交Html编辑器内容

自在修行 2011-09-17 12:40:07
我使用的是xheditor编辑器,如果内容为纯文字,提交正常,如果进行了格式修饰则无法提交,调试脚本时也没有任何错误提示,本以为是由于获取的内容中含有'"'导致,替换为"''"还是不行,到底该如何做?

var editor = $('#content')[0].xheditor;

var notice_content = editor.getSource();
notice_content = notice_content.replace(/\"/g,"''");
$.post("notice_addModi.aspx?action=post", {

title: $("#title").val(),
content: notice_content
}, function (data) {
$.messager.alert('提示', data, 'info'); // 把返回的数据添加到页面上
}
);
...全文
371 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
长杆 2014-04-11
  • 打赏
  • 举报
回复
在哪里改ASPX页面禁步提交
自在修行 2011-10-31
  • 打赏
  • 举报
回复
是因为 “aspx页面是否设置了 禁止提交 html标签”,改了一下就行了
另外,xheditor编辑器的内容,直接使用 $("#content").val() 获取就行无需使用
“var editor = $('#content')[0].xheditor;

var notice_content = editor.getSource();”
这样反而老出错
licip 2011-09-17
  • 打赏
  • 举报
回复
有特殊符号就转义吧。
inetfuture 2011-09-17
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 kk3k2005 的回复:]
lz请先考虑和查找 无法提交 具体是哪个环节影响 使得无法提交 这样才有助于解决问题


个人 以为 lz用了aspx 该aspx页面是否设置了 禁止提交 html标签(默认情况下 是禁止的)
[/Quote]

……
content: htmlEncode(notice_content)
……

function htmlEncode(s){
s = s.replace(/</g, '<');
s = s.replace(/>/g, '>');
return s;
}
KK3K2005 2011-09-17
  • 打赏
  • 举报
回复
lz请先考虑和查找 无法提交 具体是哪个环节影响 使得无法提交 这样才有助于解决问题


个人 以为 lz用了aspx 该aspx页面是否设置了 禁止提交 html标签(默认情况下 是禁止的)
lufeng589674 2011-09-17
  • 打赏
  • 举报
回复
在post()前,做如下:
alert(notice_content);弹出这个的值看看,到底是什么?看看与纯文本有什么区别,就知道了。

52,797

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 Ajax
社区管理员
  • Ajax
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧