0 Replies Latest reply on Dec 8, 2011 1:53 AM by Lu Han

    invoke eval and get unexpected identifier [upgrade  from rf3.3.3 torf4.1.0.CR2]

    Lu Han Newbie

      This is the code works well on rf3.3.3:

      <a4j:form id="asyncform">

                    <a4j:jsFunction name="loadByJson"

                              action="#{popularUtilization.loadChartData}"

                              data="#{popularUtilization.jsonData}"

                              ajaxSingle="true"

                              ignoreDupResponses="true"

                              eventQueue="foo"

                              oncomplete="updateData(data)"/>

                </a4j:form>

       

      <script type="text/javascript">

                loadByJson();

       

                function updateData(jsonData) {

                          var barModel = eval('(' + jsonData + ')');

                          generateChart(barModel);

                          generateFlotChart(barModel);

                }

      </script>

       

      And I found the data property doesn't work, so, I changed the code as:

      <h:form id="asyncform">

          <a4j:jsFunction name="loadByJson"

                    action="#{popularUtilization.loadChartData}"

                    ajaxSingle="true"

                    ignoreDupResponses="true"

                    eventQueue="foo"

                    oncomplete="updateData(#{popularUtilization.jsonData})"/>

      </h:form>

       

      <script type="text/javascript">

                loadByJson();

       

                function updateData(jsonData) {

                          var barModel = eval('(' + jsonData + ')');

                          generateChart(barModel);

                          generateFlotChart(barModel);

                }

      </script>

       

      It doesn't work now, and the error message from the chrome debug at this line:

      var barModel = eval('(' + jsonData + ')');

      error:

      Uncaught SyntaxError: Unexpected identifier.

       

      Please help to check it.

       

      Thanks!

       

      Eric Han