最新文章专题视频专题问答1问答10问答100问答1000问答2000关键字专题1关键字专题50关键字专题500关键字专题1500TAG最新视频文章推荐1 推荐3 推荐5 推荐7 推荐9 推荐11 推荐13 推荐15 推荐17 推荐19 推荐21 推荐23 推荐25 推荐27 推荐29 推荐31 推荐33 推荐35 推荐37视频文章20视频文章30视频文章40视频文章50视频文章60 视频文章70视频文章80视频文章90视频文章100视频文章120视频文章140 视频2关键字专题关键字专题tag2tag3文章专题文章专题2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章专题3
当前位置: 首页 - 科技 - 知识百科 - 正文

Json实现异步请求提交评论无需跳转其他页面_jquery

来源:懂视网 责编:小采 时间:2020-11-27 21:27:57
文档

Json实现异步请求提交评论无需跳转其他页面_jquery

Json实现异步请求提交评论无需跳转其他页面_jquery:主要将代码粘贴,通过阅读代码理解其中的相关逻辑。 html代码: 已有评论: js代码: $(#send).click(function () { $.get(doSave.ashx, { //调用json插件 u_name: $(#username1).val(), //json数据
推荐度:
导读Json实现异步请求提交评论无需跳转其他页面_jquery:主要将代码粘贴,通过阅读代码理解其中的相关逻辑。 html代码: 已有评论: js代码: $(#send).click(function () { $.get(doSave.ashx, { //调用json插件 u_name: $(#username1).val(), //json数据

主要将代码粘贴,通过阅读代码理解其中的相关逻辑。

html代码:

 
 
已有评论: 
 

js代码:

插件代码:

<%@ WebHandler Language="C#" Class="doSave" %> 

using System; 
using System.Web; 

public class doSave : IHttpHandler 
{ 

public void ProcessRequest(HttpContext context) 
{ 

var dic = new System.Collections.Generic.Dictionary(); //存储的集合 
string jsonStr = "{}"; //新建字符串jsonStr 

context.Response.ContentType = "text/json"; //定义返回的内容类型为json 

string uname = context.Request.QueryString[0]; //获取请求参数中第一个参数,也可以直接使用uname 

string commet = context.Request.QueryString[1]; //定义字符串uname、commet为context请求查询的字符串context.Request.Params["username"];QyertStrubg:查询字符串 

dic.Add("username", uname); //将字符串添加到对象中 

dic.Add("content", commet); 

jsonStr = Newtonsoft.Json.JsonConvert.SerializeObject(dic); //序列化集合为json字符串 

context.Response.Write(jsonStr); 
} 

public bool IsReusable 
{ 
get 
{ 
return false; 
} 
} 

}

此处效果即为,在输入框中输入相关文字,点击提交,下方会自动将书写的文字进行展示,无需跳转其他页面。

文档

Json实现异步请求提交评论无需跳转其他页面_jquery

Json实现异步请求提交评论无需跳转其他页面_jquery:主要将代码粘贴,通过阅读代码理解其中的相关逻辑。 html代码: 已有评论: js代码: $(#send).click(function () { $.get(doSave.ashx, { //调用json插件 u_name: $(#username1).val(), //json数据
推荐度:
标签: 跳转 json jQuery
  • 热门焦点

最新推荐

猜你喜欢

热门推荐

专题
Top