includes/clientside/static/autocomplete.js
changeset 174 d74ff822acc9
parent 73 0a74676a2f2f
child 212 d57af0b0302e
--- a/includes/clientside/static/autocomplete.js	Tue Oct 09 16:14:55 2007 -0400
+++ b/includes/clientside/static/autocomplete.js	Fri Oct 12 14:41:51 2007 -0400
@@ -160,7 +160,24 @@
         thediv.id = id;
         unObj.onblur = function() { destroyUsernameDropdowns(); }
         
-        eval(ajax.responseText);
+        var response = String(ajax.responseText) + ' ';
+        if ( response.substr(0,1) != '{' )
+        {
+          new messagebox(MB_OK|MB_ICONSTOP, 'Invalid response', 'Invalid or unexpected JSON response from server:<pre>' + ajax.responseText + '</pre>');
+          return false;
+        }
+        
+        response = parseJSON(response);
+        var errorstring = false;
+        if ( response.mode == 'error' )
+        {
+          errorstring = response.error;
+        }
+        else
+        {
+          var userlist = response.users_real;
+        }
+        
         if(errorstring)
         {
           html = '<span style="color: #555; padding: 4px;">'+errorstring+'</span>';