views:

37

answers:

1

Hello Everyone, 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.

A: 

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:

  response.write(status + "," + numChatMessages);

in your javascript:

  var elm = str.split(",");
  var userstatus = elm[0];
  var numChatMessages = elm[1];

this is kind-of ugly, but would work for your purpose.

Håvard
thanks, but can you tell me some example of json, because i did't use it ever.
Abhisheks.net