2 Replies Latest reply on Oct 10, 2007 6:36 PM by snnyannd

    jsFunction "data" syntax error issue

      I am using the following tags to get server data:

      <a4j:form ajaxSubmit="true">
      <a4j:jsFunction name="getAllProcesses" data="#{bean.blah}"
      oncomplete="initAllProcs(data.foo)" />
      </a4j:form>

      The server side code is as follows:

      public JSONObject getAllProcesses() {
      JSONObject x = new JSONObject();
      x.put("foo","bar");
      return x;
      }

      I get the following AJAX Response:
      <![CDATA[ {'foo':'bar'} ]]>initAllProcs(data)

      When getJSON is called I see the following error in the log:
      debug[10:18:37,523]: call getElementById for id= org.ajax4jsf.oncomplete
      debug[10:18:37,523]: Call request oncomplete function after processing updates
      debug[10:18:37,539]: call getElementById for id= _ajax:data
      error[10:18:37,539]: Error on parsing JSON data syntax error

      I believe that getJSON calls window.eval on (<![CDATA[ {'foo':'bar'} ]]>) which generates a syntax error

        • 1. Re: jsFunction

          Correction to the server side code:

          public JSONObject getBlah() {
          JSONObject x = new JSONObject();
          x.put("foo","bar");
          return x;
          }

          • 2. Re: jsFunction

            Never Mind...I had a javascript class called Node elsewhere in the project. This caused a namespace clash with the Node in AjaxScript.js