HTML:
<!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> <title>使用JQuery调用XML实现无刷新即时聊天</title> <script src="/UploadFiles/2021-04-02/jquery-1.8.2.min.js">Chat.ashx:
<%@ WebHandler Language="C#" Class="Chat" %> using System; using System.Web; using System.Xml; public class Chat : IHttpHandler { public void ProcessRequest (HttpContext context) { context.Response.ContentType = "text/plain"; string strContent = context.Request.QueryString["c"].ToString(); string strFromId = context.Request.QueryString["f"].ToString(); string strSendId = context.Request.QueryString["s"].ToString(); int intSuccess = 0; string strDate = DateTime.Now.ToString("HH:mm:ss"); XmlDocument xmlDoc = new XmlDocument(); try { xmlDoc.Load(context.Server.MapPath("Chat.xml")); XmlNode root = xmlDoc.SelectSingleNode("chat"); XmlElement xmlE = xmlDoc.CreateElement("message"); xmlE.SetAttribute("fId", strFromId); xmlE.SetAttribute("sId", strSendId); XmlElement xmlEd = xmlDoc.CreateElement("datetime"); xmlEd.InnerText = strDate; xmlE.AppendChild(xmlEd); XmlElement xmlEc = xmlDoc.CreateElement("content"); xmlEc.InnerText = strContent; xmlE.AppendChild(xmlEc); root.AppendChild(xmlE); xmlDoc.Save(context.Server.MapPath("Chat.xml")); intSuccess = 1; } catch(Exception ex) { throw ex; } context.Response.Write(intSuccess); } public bool IsReusable { get { return false; } } }以上所述是小编给大家介绍的使用jQuery调用XML实现无刷新即时聊天,希望对大家有所帮助,如果大家有任何疑问欢迎给我留言哦!
标签:
jquery,无刷新即时聊天
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件!
如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
狼山资源网 Copyright www.pvsay.com
暂无“使用jQuery调用XML实现无刷新即时聊天”评论...