I have a javascript interface for a webchat which receives JSON data
from the server. Everything works smoothly using for...in loop. Now
the problem is that after adding prototype.js script in the page
header the response data is somehow affected with Prototype and loops
through the Prototype script as it would be part of the response.

For example the debugging area is supposed to show undefined messages
from the server (good for PHP debugging) but with Prototype it
displays all "var Enumerable" part of the Prototype code, userlist
gets full of "undefined" and etc.

The JSON message parsing code is basically as follows:

var response = eval("(" + request.responseText + ")");
for (var id in response.messages) {
  var msg = response.messages[id];
  var type = msg.type;
  if (type == 'msg') {
    chatlog.appendChild(newChatMsg("["+msg.time+"] <"+msg.user
+"> "+msg.text));
  }

  // many other types

  debug_area.appendChild(newMsgElement(msg,"debug"));
}

I'm not sure how I should change the code to get it working. Maybe
someone could give a push?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Spinoffs" group.
To post to this group, send email to rubyonrails-spinoffs@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to