xmlhttp 请求
在我的应用程序中,我使用 xmlHttp,它通过 javascript 函数调用来检查在线用户。 这个 xmlhttp 调用了一个 asp 页面,它通过 response.write 检查当前状态和响应。 此功能进展顺利,但现在我想检查另一件事以及用户状态,即该特定用户是否有任何新的聊天消息(如果有),那么它应该在用户窗口上可见。
现在我希望在那个(用于检查用户状态的)asp 页面中也检查新的聊天消息,以便不创建其他功能或其他 xmlhttp。
所以请告诉我一些事情我应该如何处理。
In my application i am using xmlHttp that is calling by a javascript function to check the online user.
this xmlhttp called a asp page that checks the current status and response by response.write .
this functionality is going well but now i want to check another thing along with user status, that is is there any new chat message for that particular user if any then the it should be visible on user window.
now i want that in that( which is using for checking user status) asp page the new chat messaged be also checked so that no other function or other xmlhttp be created.
so please tell me something how should i handle it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当从xmlhttp调用的ASP页面返回数据时,应该考虑以结构化的方式返回数据,这样更容易被网页解析。
我建议您使用 ie JSON(请参阅维基百科)来构建数据,以便您稍后能够添加更多字段。
如果您不想使用 JSON,您还可以将聊天消息的数量与用户状态一起发送,中间用逗号分隔,然后用 javascript 分割文本,即:
in your asp:
in your javascript:
this is kind-of丑陋,但可以达到你的目的。
When returning data from the ASP page called by xmlhttp, you should consider returning the data in a structured manner, so it is easier to parse by the web page.
I recommend that you use i.e. JSON (see wikipedia) to structure the data, so that you'll be able to add more fields later.
If you don't want to use JSON, you can also send the number of chat messages together with user status with a comma between, and split the text with javascript, i.e.:
in your asp:
in your javascript:
this is kind-of ugly, but would work for your purpose.