cerulean Posted June 10, 2013 Share Posted June 10, 2013 I've been using XMLLoader to write XML files via a php script: private static function sendXML($xml:XML):void { // declaring var xmlcontents String. You should set this first. var xmlcontents:String = $xml.toString(); // declaring var SERVER_PATH String. This is the path for the saving-xml.php. var SERVER_PATH:String = TTConstants.SERVER_PATH + "/php/"; // declaring var foldername String. This is the folder container of the saved XML file var foldername:String = "../xml"; // declaring var dataPass URLVariables var dataPass:URLVariables = new URLVariables(); var previewRequest:URLRequest = new URLRequest(TTConstants.SERVER_PATH + "/php/ttwrite.php"); previewRequest.method = URLRequestMethod.POST; // setting dataPass variables to be passed to PHP dataPass.filename = USER_XML_FILENAME; dataPass.xmlcontents = xmlcontents; dataPass.foldername = foldername; // passing dataPass data PHP previewRequest.data = dataPass; var loader:XMLLoader = new XMLLoader(previewRequest, {onComplete:serverSendComplete,onIOError:onIOError,onSecurityError:onSecError,onError:onError}); // calling the PHP or loading the PHP loader.load(); } I want to call a PHP script to simply delete ("unlink") an xml file on the server. Can I use XMLLoader to do this as well (for ease of complete and error functions -- callbacks instead of adding/removing event listeners)? There's no XML loading involved, so I don't know if it's 'kosher' - var deleteRequest:URLRequest = new URLRequest("http://localhost/tt/php/ttdelete.php"); deleteRequest.method = URLRequestMethod.POST; var loader:XMLLoader = new XMLLoader(deleteRequest, {onComplete:serverDeleteComplete,onIOError:onIOError,onSecurityError:onSecError,onError:onError}); // calling the PHP or loading the PHP loader.load(); Link to comment Share on other sites More sharing options...
Carl Posted June 12, 2013 Share Posted June 12, 2013 Yeah, its a little unorthodox, and I haven't tried if for myself, but give it a shot. Its not the type of thing we can support or test unfortunately. I would think that if your server produces a response from that request, it could work fine. Link to comment Share on other sites More sharing options...
cerulean Posted June 12, 2013 Author Share Posted June 12, 2013 OK,thanks. It is fine, however, to use the XMLLoader to send XML data to a php script to write to the server, though? I'm sure I read this in the APIs or forum or somewhere — and I'm using the technique (which seems to work fine) in code shipping next week, so I want to be sure. No, of course, never ask you to troubleshoot PHP code (I'm not a PHP person but found some workable code I could use, which, as said, works fine). But I'm keen to know if XMLLoader is designed to load and send XML data, via a technique as below. As I said, I believe I read that it was (but perhaps I'm dreaming :->) private static function sendXML($xml:XML):void { // declaring var xmlcontents String. You should set this first. var xmlcontents:String = $xml.toString(); // declaring var SERVER_PATH String. This is the path for the saving-xml.php. var SERVER_PATH:String = TTConstants.SERVER_PATH + "/php/"; // declaring var foldername String. This is the folder container of the saved XML file var foldername:String = "../xml"; // declaring var dataPass URLVariables var dataPass:URLVariables = new URLVariables(); var previewRequest:URLRequest = new URLRequest(TTConstants.SERVER_PATH + "/php/ttwrite.php"); previewRequest.method = URLRequestMethod.POST; // setting dataPass variables to be passed to PHP dataPass.filename = USER_XML_FILENAME; dataPass.xmlcontents = xmlcontents; dataPass.foldername = foldername; // passing dataPass data PHP previewRequest.data = dataPass; var loader:XMLLoader = new XMLLoader(previewRequest, {onComplete:serverSendComplete,onIOError:onIOError,onSecurityError:onSecError,onError:onError}); // calling the PHP or loading the PHP loader.load(); } Link to comment Share on other sites More sharing options...
GreenSock Posted June 13, 2013 Share Posted June 13, 2013 Is something breaking for you? You should be able to send string variables to the server, yes. We can't speak to interpreting or validating that on the server-side, though. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now