0 Replies Latest reply on Mar 18, 2008 4:30 PM by tam2000k2

    Datagrid from JavaScript from PHP

    tam2000k2
      Hi Everyone,

      Let me start by saying that this application worked until our server crashed, so I do believe that there is some kind of setting within the server that is preventing this from working once again, but our server is set to all default values for now.

      I basically have a datagrid that is populated via the FABridge component which receives an array from JavaScript, which receives the info from a PHP script, which retrieves a result set from MySQL.

      Once more, this worked prior to the server crashing three Sundays ago. For now, I run the PHP file which generates the string that I want to send to JavaScript, which then sends it to the datagrid. I copy & paste the string:
      [code]
      mySeFunc([{SHOWS: "some_show ", GENDER: "Male", AGE: "21", FIRST_NAME: "Joe", LAST_NAME: "Somebody", EMAIL_ADDRESS: "something@yahoo.com", PHONE_NUMBER: "5555555555", CITY: "Some_city", STATE: "Some_state", ZIP: "11111", PICTURE: "some_pic.jpg"}]);
      [/code]

      If I take this string, then copy & paste it in place of a variable -- "response":
      [code]
      function handleResponsePost()
      {
      if(http.readyState == 4 && http.status == 200)
      {
      var response = http.responseText;
      if(response)
      {
      window.onload = eval(response);

      }
      }
      }

      As such:
      function handleResponsePost()
      {
      if(http.readyState == 4 && http.status == 200)
      {
      var response = http.responseText;
      if(response)
      {
      window.onload = eval(mySeFunc([{SHOWS: "some_show ", GENDER: "Male", AGE: "21", FIRST_NAME: "Joe", LAST_NAME: "Somebody", EMAIL_ADDRESS: "something@yahoo.com", PHONE_NUMBER: "5555555555", CITY: "Some_city", STATE: "Some_state", ZIP: "11111", PICTURE: "some_pic.jpg"}]);

      }
      }
      }
      [/code]

      Then the datagrid populates just fine. And it used to receive these Strings from an echo coming from my PHP file which retrieved a resultset from MySQL before the server crashed. As follows:

      [code]
      echo "mySeFunc([".$myComboVar2."]);";
      [/code]

      Now if I copy & paste the same String, that I receive from the PHP file, then I will see a JavaScript error from the console:
      [code]
      echo "mySeFunc([{SHOWS: "some_show ", GENDER: "Male", AGE: "21", FIRST_NAME: "Joe", LAST_NAME: "Somebody", EMAIL_ADDRESS: "something@yahoo.com", PHONE_NUMBER: "5555555555", CITY: "Some_city", STATE: "Some_state", ZIP: "11111", PICTURE: "some_pic.jpg"}]);";
      [/code]

      The JavaScript code which sends the code to the Flex app:
      [code]
      function mySeFunc(someArrayComing)
      {
      var flexApp = FABridge.fab.root();
      flexApp.myActionScriptFromJavascript(someArrayComing);
      }
      [/code]

      The code within Flex which receives the String:
      [code]
      public function myActionScriptFromJavascript(someArrayComing:Array):void
      {
      dataGrid.dataProvider = someArrayComing;
      dataGrid.validateNow();
      }
      [/code]

      What configuration in the server could cause the same String literal to work directly from Javascript and not to work if it's passed from PHP? I know that it cannot be the length of the String literal because, I have tried pasting just ONE record and it still gives me the same error:
      [code]
      Error: missing } in XML expression
      Source File: http://www.somedomain.com/someJSscript.js Line 56
      mySeFunc([{SHOWS: "some_show ", GENDER: "Male", AGE: "21", FIRST_NAME: "Joe", LAST_NAME: "Somebody", EMAIL_ADDRESS: "something@yahoo.com", PHONE_NUMBER: "5555555555", CITY: "Some_city", STATE: "Some_state", ZIP: "11111", PICTURE: "some_pic.jpg"}])
      [/code]

      Which the arrow pointing in the JavaScript Console to the place where the error lies, is after the ":" following SHOWS:

      Once more, all of this worked perfectly for months. We have a database of over 23,000 records. For now, each morning I run the PHP script, copy & paste the result set in place of the variable "response" and the datagrid loads within 20 seconds on Macs and 2 minutes on PCs.

      For obvious reasons, I'd rather not be copy & pasting every morning as the db grows daily.

      Thanks in advance :-)