Use jQuery to call XML for instant chat without refreshing, jqueryxml
HTML:
<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
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;}}}
The above section describes how to use jQuery to call XML for instant chat without refreshing. I hope it will be helpful to you. If you have any questions, please leave a message!