AJAX Same Origin Policy issues with 3rd party API on p2p network

nedflanders

New Member
I'm working on a HTML5 webapp to be used in controlling a 3rd party robotic device that has a TXAS XML API Web Service used for accepting commands. I have no access to change the 3rd Party API, and it is very basic. It has a structured XML command format with basic authorization and it doesn't understand JSON or JSONP, just straight XML.I am trying to write this as elegantly as possible and have the app completely self-contained in the file to be loaded onto the control device (tablet/smartphone) without need of any interaction with a remote server after it has been loaded. i.e. this will be a p2p application between the tablet and the device it's controlling.I think immediately I am running into the S.O.P. limitation which is causing problems but I'm not sure how to get around it since the code is local to the tablet and the device I'm controlling is not.Here is the code I'm trying to execute:\[code\]function postXML(strIN){ $.ajax({ type: "POST", url: "http://1.1.1.1/putxml", contentType: "text/xml", datatype: "xml", data: strIN, processData: false, beforeSend: function (xhr){ xhr.setRequestHeader("Authorization","Basic " + btoa("user:pass")); }, error: function(requets, error) { alert("error:" + error);} }); }$("#preset1").click(function(){ var str = '<Command><Preset><Activate><PresetId>1</PresetId></Activate></Preset></Command>'; postXML(str); });\[/code\]The code executes clean in safari when launched from the local drive; however, it will not work with chrome, firefox, or IE when launched in the same manner (triggers the error event).Being that most of the devices that will be using this are iPhones/ipads I didn't think this to be a big deal, but, my method of loading the page onto the device is via HTTP and then to save locally. When done in this manner it also fails on safari as well. I've used a diff-merge program to verify that the HTTP loaded code and the locally sourced code are identical and they are, but for some reason the HTTP loaded code will not execute (triggers the error event).Am I hitting the S.O.P. limitation here? I've looked for possible ways around this but they all seem to require an external server or proxy which is not an option for my deployment scenario.I should also note that I am not expecting anything back from the device, nor do I require to have any other interaction with it apart from just POST'ing XML to it's webservice.
 
Back
Top