2 Replies Latest reply on Jan 21, 2009 7:16 PM by quipuscott

    Error when retrieving data from remote url

    quipuscott
      Hello,

      I'm trying to do something that should be very simple -- letting a user enter something in a textbox, then using that data as a script parameter when calling a remote cgi script, and returning the results to the screen.

      The remote cgi is sending data in plain text. I have looked at several examples, and I've tried using an XMLHttpRequest, I've tried using the servicemonitor.swf methods, and I've tried with URLRequest and URLLoader methods. All fail in one way or another.

      Here's the code for the URLRequest/URLLoader method...

      function fetchISSN(myform) {
      air.trace("Starting Fetch");

      var mytitle = myform.title.value;
      air.trace("TITLE: " + mytitle);

      var reqURL = " http://grlinker.coalliance.org/grbin/ilu_rmt.cgi";
      air.trace("URL: " + reqURL);

      var variables = new air.URLVariables("title=" + mytitle + "&isf=plain");
      air.trace("URLPARMS: " + variables);

      // var element = document.getElementById('results');

      var request = new air.URLRequest(reqURL);
      air.trace("Request Object Created");

      request.data = variables;
      air.trace("Data Added to request");

      request.method = air.URLRequestMethod.POST;


      var loader = new air.URLLoader();
      air.trace("Loader Object Created");


      loader.addEventListener(air.Event.COMPLETE, loadComplete);
      loader.addEventListener(air.Event.OPEN, loadOpen);



      try {
      loader.load(request);
      } catch(e) {
      alert('Could NOT load data: ' + e);
      }

      } // end of function fetchISSN

      function loadComplete(event) {
      // alert('Downloaded ' + loader.bytesTotal);
      alert('Complete');
      // element.innerText = loader.data;
      } // end of function loadComplete()

      function loadOpen(event) {
      alert('Downloading');
      } // end of function loadComplete()

      And the HTML that calls it...

      <table width="280" border="1" align="center">
      <tr><td align="center">
      <font size="2">Enter a title and click submit.</font>
      <form name="issn">
      <input type="text" name="title" /><br>
      <input type="submit" name="submit" value="Submit" onClick="javascript:fetchISSN(this.form)" />
      </form>
      </td></tr>
      </table>

      Things go fine until it hits the loadComplete function. At that point, the following error is generated...

      Error: The application attempted to reference a JavaScript object in an HTML page that is no longer loaded.
      at __HTMLScriptFunction/throwJSObjectDead()
      at flash.events::EventDispatcher/dispatchEventFunction()
      at flash.events::EventDispatcher/dispatchEvent()
      at flash.net::URLLoader/onComplete()

      Can anyone give me any advice or even a reason for this failure. I did find a bug about this in the bugtracker, it says it is resolved with an "external" resolution. I'm not sure what that means. Is there a patch I'm missing? Am I doing something really stupid?

      Just for reference, I'm on a Mac running OS X 10.5.6, using the SDK for development.

      Thanks!

      Scott