首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > Ajax >

~百度编辑器ueditor通过ajax提交报错!立地给分!

2013-12-05 
~~~~~~~~~~~~~百度编辑器ueditor通过ajax提交报错!马上给分!~~~~~~~~~~~~~~~%@ Page LanguageC# AutoE

~~~~~~~~~~~~~百度编辑器ueditor通过ajax提交报错!马上给分!~~~~~~~~~~~~~~~


<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="CSPMSWeb.Test.WebForm1" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <link href="/css/index_skin01.css" rel="stylesheet" type="text/css" id="indexSkin" />
    <title>330CPS TEST</title>
</head>
<body>
  <div id="editor"></div>
  <div class="mt_10 center">
    <input class="btnsave mr_20" type="button" onclick="SaveInfo('save')" value="保存" />
  </div>
</body>
<script type="text/javascript" src="/js/jquery/jquery.1.7.1.min.js"></script>
<script type="text/javascript" src="/js/ueditor/ueditor.config.js"></script>
<script type="text/javascript" src="/js/ueditor/ueditor.all.js"></script>
<script language="javascript">
var editorhtml;
//实例化编辑器
UE.getEditor('editor');

function SaveInfo(state){   
    getContent();         //获取带格式的富文本内容
    alert(editorhtml);
    $.ajax({            
            url: "WebForm1.aspx",            
            data:
            {
                act: state,                                 
                content: editorhtml
            },
            success: function(data) {    
                alert("保存成功!"); 
            },
            error: function(data){
              alert("Save Func Error!");
            }
        });        
}

function getContent() {
    var arr = [];
    arr.push(UE.getEditor('editor').getContent());
    editorhtml=arr.join("\n")
}
</script>
</html>




做了一个最简单的WebForm1.aspx页面,然后在百度编辑框ueditor中输入abc,
点击保存,alert出来是"<p>abc<br/></p>",
通过ajax方法,直接报错alert("Save Func Error!");


谁碰到过类似的问题,可以说说吗?




[解决办法]
提交包含html代码的内容到aspx页面去会出错,要给page指令添加 ValidateRequest="false"

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="CSPMSWeb.Test.WebForm1"  ValidateRequest="false"%>

热点排行