首页
IT服务
解决方案
IT实战培训
关于我们
您的位置 :
ITLead >>
技术交流
>>
软件开发
>>
前端开发
Jqueryajax Get
来源:广州中睿信息技术有限公司
发布时间:
2012/10/21 23:25:16
编辑:
itlead
阅读
1637
次
Jqueryajax Get
下面代码是jQuery post 发送数据:
1.页面代码:
<%@PageLanguage="C#"AutoEventWireup="true"CodeBehind="WebForm1.aspx.cs"Inherits="WebApplication8.WebForm1"%> <!DOCTYPEhtmlPUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <htmlxmlns="http://www.w3.org/1999/xhtml"> <headrunat="server"> <title></title> <scriptsrc="Scripts/jquery-1.4.1.min.js"type="text/javascript"></script> <scripttype="text/javascript"> $(function () { $("#submit").click(function () { $.ajax({ url: "WebForm1.aspx", type: "GET", success: function (msg) { $("#div1").html(msg); }, error: function (msg) { $("#div1").html(msg); } }); }) }); </script> </head> <body> <formid="form1"runat="server"> <div> <divid='div1'></div> <aid="submit"href="javascript:void(0)">get ajax</a> </div> </form> </body> </html>
2、WebForm1.aspx页面后台代码:
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace WebApplication1 { publicpartialclassWebForm1 : System.Web.UI.Page { protectedvoid Page_Load(object sender, EventArgs e) { Show(); } privatevoid Show() { #region StringBuilder sb = newStringBuilder(); sb.AppendLine("{exam:["); for (int i = 0; i < 10; i++) { sb.Append("{"); sb.AppendFormat("ID:'{0}'", i); sb.Append("},"); } if (sb.ToString().Contains(",")) { sb = sb.Remove(sb.ToString().LastIndexOf(','), 1); } sb.Append("]}"); WriteEnd(sb.ToString()); #endregion } protectedvoid WriteEnd(string strEnd) { Response.Clear(); Response.Write(strEnd); Response.Flush(); Response.End(); } } }
本站技术原创栏目文章均为中睿原创或编译,转载请注明:文章来自
中睿
,本站保留追究责任的权利。
相关阅读
· asp正则替换链接实现伪静态效果2013.12.04
· asp生成静态HTML(动态读取)2013.12.04
· jquery,轻松自如解决了“例外被抛出且未被接住”的报错问题2012.10.21
· JavaScript-设计模式(适配器模式)2012.10.21
· XAML传递参数到值转换类2012.10.21