之前没用过Ueditor去异步提交,最近项目需要用到这个,就下了个来用,结果可能没仔细去看Ueditor的相关介绍文档,然后自己也郁闷了一下才把它弄出来,现在可以实现异步提交了,松口气,把代码贴出来,以备参考!如果哪里写得不好,请帮我指出来哦,谢谢!
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="test.aspx.cs" ValidateRequest="false"
Inherits="WebApplication2.CommunityAdmin.test" %>
<!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">
<title></title>
<script type="text/javascript" src="ueditor/editor_all_min.js"></script>
<script type="text/javascript" src="ueditor/editor_config.js"></script>
<link rel="Stylesheet" href="ueditor/themes/default/ueditor.css" />
<script type="text/javascript" src="../Scripts/jquery-1.4.1.min.js"></script>
</head>
<body>
<script type="text/javascript">
var editor = new UE.ui.Editor();//实例
editor.render('myeditor');//渲染编辑器
$(function () {
$("#btn").click(
function () {
var nn = editor.getContent();
editor.sync();//这一句至关重要,没有它,甭想异步提交了
$.ajax(
{
url: "Handler1.ashx",
type: "post",
data: "wenben=" + nn,
success: function (data) {
alert(data);
}
}
);
});
});
</script>
<textarea name="mycontent" rows="" cols="" id="myeditor"> </textarea>
<input type="button" id="btn" />
</body>
</html>
------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------
Handler1.ashx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace WebApplication2.CommunityAdmin
{
/// <summary>
/// Handler1 的摘要说明
/// </summary>
public class Handler1 : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/plain";
context.Response.Write(context.Request["wenben"]);//这个标红色的地方要注意不要写错!
}
public bool IsReusable
{
get
{
return false;
}
}
}
}
转载请保留出处:http://www.cnblogs.com/QMM2008/p/3532929.html
标签:
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有