1 Reply Latest reply on Jan 8, 2007 1:57 PM by mac_martine

    HTTPService not responding fast enough

    dhurtig
      I am using HTTPService (named recordDetailRequest)to call a PHP script that generates XML each time a user clicks on a data grid item. After send(), I call a function that reads the lastResult and assigns values to text boxes.

      The problem I have is that the first request returns a null error. Subsequent requests work - except the values they assign are from the previous selection, and not the current selection. After debugging, I have determined that the application is not waiting for a response from the HTTPService, and tries to assign the textbox value to lastResult before it has one. After the first request, it is always one result behind. If I put a pause in, it works correctly.

      Here is the offending code:

      ----- begin code -----
      protected function recordDrillDown():void
      {

      selectedRecord = searchResultsDataGrid.selectedItem.record_id;

      recordDetailRequest.send();

      popRecordDetail();

      }

      protected function popRecordDetail():void
      {
      textboxName.text = recordDetailRequest.lastResult.subscribers.subscriber.name;
      }
      ---- end code -----

      This code works:

      ----- begin code -----

      protected function recordDrillDown():void
      {

      selectedRecord = searchResultsDataGrid.selectedItem.record_id;

      recordDetailRequest.send();

      pauseID = setInterval(popRecordDetail, 1000);

      }

      protected function popRecordDetail():void
      {
      clearInterval(pauseID);

      textboxName.text = recordDetailRequest.lastResult.subscribers.subscriber.name;
      }
      ---- end code -----

      Putting a pause in is a pretty bush league workaround. Is there some way to force the application to wait for a response from the service?