Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I POST XML data to a URL via JavaScript in an Adobe AIR app?
    text
    copied!<p>I'm writing an application that downloads an XML string from a URL and <code>POST</code>s that to another URL (that's set up to handle an incoming "<code>XML</code>" field). I've got the first part right - it downloads the XML and I can <code>alert()</code> it and all that, but I'm unable to figure out how to <code>POST</code> that data to a server.</p> <pre><code>function pull() { var myLoader = new air.URLLoader(); var myRequest = new air.URLRequest('http://something/something.xml'); myLoader.addEventListener(air.Event.COMPLETE, pulled); myLoader.load(myRequest); } function pulled(evt) { if (evt.target.bytesTotal&gt;0) { // alerting shows the full string just fine alert(evt.target.data); var myLoader = new air.URLLoader(); var myRequest = new air.URLRequest('http://someplace/push.php'); myRequest.method = air.URLRequestMethod.POST; // myVars = new air.URLVariables("xml="+evt.target.data); // // alert(evt.target.data.toUpperCase()); myRequest.data = "xml="+evt.target.data; // myVars; myLoader.dataFormat = air.URLLoaderDataFormat.TEXT; myLoader.addEventListener(air.Event.COMPLETE, pushed); myLoader.load(myRequest); } } </code></pre> <p>I made the 2nd server PHP <code>echo</code> the contents of the <code>xml</code> variable, but I'm just unable to get the exact contents of the XML string. There is something I'm doing wring with the <code>myRequest.data</code> and/or <code>dataFormat</code> bit.</p> <p>Can someone just figure this out? I know it's probably a simple thing, but I'm at my wit's end right now.</p> <p>This is my first AIR app.</p> <p>Another related question (or sub-question) is that...</p> <pre><code>alert(evt.target.data); // shows an alert box with the XML alert(typeof evt.target.data); // shows String alert(evt.target.data.toUpperCase()); // shows the xml converted to upper case alert(encodeURI(evt.target.data)); // shows up blank. alert(escape(evt.target.data)); // shows up blank. </code></pre> <p>Why??</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload