listChat.aspx.cs 源代码:
protected void Page_Load(object sender, EventArgs e)
{
string strSessionID = Request.QueryString("cDialogID");
string strsName = Request.QueryString("sName");
string strcName = Request.QueryString("cName");
string strContent = Request.QueryString("cContent");
string strIP = Request.QueryString("cIP");
string strRevert = Request.QueryString("boolRevert");
Response.Write(strSessionID, strsName, strcName, strIP, strRevert);
ConnectionStringSettings s = ConfigurationManager.ConnectionStrings["connSONORO"];
SqlConnection conn = new SqlConnection(s.ConnectionString);
SqlCommand cmdInsert = conn.CreateCommand();
cmdInsert.CommandText = "proc_insertChat";
cmdInsert.CommandType = CommandType.StoredProcedure;
cmdInsert.Parameters.Add("@SessionID", strSessionID);
cmdInsert.Parameters.Add("@sName", strsName);
cmdInsert.Parameters.Add("@cName",strcName);
cmdInsert.Parameters.Add("@ChatContent", strContent);
cmdInsert.Parameters.Add("@boolBillRead", 0);
cmdInsert.Parameters.Add("@boolJackRead", 0);
cmdInsert.Parameters.Add("@boolRevert", 0);
try
{
conn.Open();
cmdInsert.ExecuteNonQuery();
}
catch
{ }
finally
{
conn.Close();
}
}
client.html 源代码
function doRequestUsingGet()
{
createXMLHttpRequest();
var quertString = "listChat.aspx?";
quertString = quertString + createQueryString() + "×tamp=" + new Date().getTime();
xmlHttp.onreadystatechange = handleStateChange;
xmlHttp.open("GET",quertString,true);
xmlHttp.send(null);
alert("Message use getmethod is sended! Message is " + quertString);
}
function createQueryString()
{
var cDialogID = "0000000000";
var cContent = document.getElementById("txtMessage").value;
var cIP = "127.0.0.1";
var cName = document.getElementById("divclientName").outerText;
var sName = document.getElementById("divstoreName").outerText;
var sQueryString = "cDialogID=" + cDialogID;
sQueryString += "&cName=" + cName;
sQueryString += "&sNmae=" + sName;
sQueryString += "&cContent=" + cContent;
sQueryString += "&cIP=" + cIP;
sQueryString += "&boolRevert=1";
return sQueryString;
}
是不是我哪里发送得有问题啊.
7 个解决方案
#1
555 up
#2
调试你的js.不响应估计是你的js有问题。
#3
晕...既然open()方法的最后一个参数是true,也就是异步模式...
那你应该去handleStateChange()里面读取信息...
xmlHttp.onreadystatechange = handleStateChange;
那你应该去handleStateChange()里面读取信息...
xmlHttp.onreadystatechange = handleStateChange;
#4
都没见你用一句代码来取回你Xmlhttp的值呀,怎么会有反应呢?
Web开发学习站:http://www.lbsxp.com
QQ群:14415733
Web开发学习站:http://www.lbsxp.com
QQ群:14415733
#5
搞定了.今天来结账的.
#6
各位正解。我也不知道怎么犯了这样的错误,可能当时不太会吧。..谢谢各位了.
#7
Response.Write(strSessionID, strsName, strcName, strIP, strRevert);会返回一个具有HTML标签的文档,如果不想要有HTML标记,可在后面直接根Response.End();
如:
Response.Write(strSessionID, strsName, strcName, strIP, strRevert);
Response.End();
如:
Response.Write(strSessionID, strsName, strcName, strIP, strRevert);
Response.End();
#1
555 up
#2
调试你的js.不响应估计是你的js有问题。
#3
晕...既然open()方法的最后一个参数是true,也就是异步模式...
那你应该去handleStateChange()里面读取信息...
xmlHttp.onreadystatechange = handleStateChange;
那你应该去handleStateChange()里面读取信息...
xmlHttp.onreadystatechange = handleStateChange;
#4
都没见你用一句代码来取回你Xmlhttp的值呀,怎么会有反应呢?
Web开发学习站:http://www.lbsxp.com
QQ群:14415733
Web开发学习站:http://www.lbsxp.com
QQ群:14415733
#5
搞定了.今天来结账的.
#6
各位正解。我也不知道怎么犯了这样的错误,可能当时不太会吧。..谢谢各位了.
#7
Response.Write(strSessionID, strsName, strcName, strIP, strRevert);会返回一个具有HTML标签的文档,如果不想要有HTML标记,可在后面直接根Response.End();
如:
Response.Write(strSessionID, strsName, strcName, strIP, strRevert);
Response.End();
如:
Response.Write(strSessionID, strsName, strcName, strIP, strRevert);
Response.End();