Loading ...
Sorry, an error occurred while loading the content.

Re: [json] Re: [question] parse json with ajax

Expand Messages
  • Philip Tellis
    ... Ugh, don t do that. Apart from screwing with the scope of responsejson, it also causes a security problem, and it s overkill. If you must use eval, do it
    Message 1 of 7 , Aug 15, 2007
    • 0 Attachment
      On 15/08/07, Michal Migurski <mike-jsonphp@...> wrote:
      >
      > This should help:
      > eval("var responsejson = (" + responsetext + ");");
      > alert(responsejson['depth1']['depth2']['depth3'];

      Ugh, don't do that. Apart from screwing with the scope of
      responsejson, it also causes a security problem, and it's overkill.
      If you must use eval, do it this way:

      var responsejson = eval( "(" + o.responseText + ")" );

      That won't take away the security problems with eval, but it will make
      sure that responsejson is in current scope.
    Your message has been successfully submitted and would be delivered to recipients shortly.