php - Ajax connection from Intex XDK failing -


I have a problem connecting to a php page using Ajax from my phone. I've made the transaction as simple as possible. The server side code is:

  & lt ;? Php echo (json_encode ('success')); ? & Gt;   

Customer side code is:

  $ Ajax ({'url': "http://www.skynet.ie/~lobo/ test.php", 'success': function (result) {warning (result);}, 'error': function (XMLHttpRequest, TextStatus, errorThrown) {warning (JSON.stringify (XMLHttpRequest));}});   

I get a successful response when testing with the Intel XDK emulator. When I launch the app from my phone (IOS):

readyState: 0, response text: "", position: 0, status text: "error"

From the error function I have tried to add

  header ('Content-Type: Application / Jason; Charset = UTF-8'); Header ("Access-Control-Permission-Origin: *");   

To make no profit on the php page. I've set $$. Support.cors = true; At the local level I have tried to use $ .getjson and I feel that about just about every AJAX option I found to be relevant, I get a successful response in connecting to the phone and I can get a response from my site in the emulator. I really do not know what can be wrong when I try to connect to the server from the phone. I am thinking that any insights will be greatly appreciated.

Stephen

You are facing a Corrosion problem, try the following :

In order to make an AJAX request on a foreign website between apps created by Intel XDK or XDK, I recommend that you xhr.js

For example,

  & lt ;! DOCTYPE html & gt; & Lt ;! - HTML5 Functionality - & gt; & Lt; Html & gt; & Lt; Top & gt; & Lt; Title & gt; Your new app & lt; / Title & gt; & Lt; Meta http-equiv = "content-type" content = "text / html; charset = UTF-8" & gt; & Lt; Meta name = "viewport" content = "width = device-width, initial-level = 1.0, maximum-scale = 1.0, minimum-level = 1.0, user-scalable = 0" /> & Lt; Style type = "text / css" & gt; / * Text field * / * {-webkit-user-select: none; Prevent copy paste for all elements except; Webkit-Tap-Highlight-Color: RGBA (255, 255, 255, 0); } Input, Textera {-VBKIT-user-selection: text; Body {background color: white; Color: black} & lt; / Style & gt; & Lt; script src = 'intelxdk.js' & gt; & Lt; / Script & gt; & Lt; script src = 'xhr.js' & gt; & Lt; / Script & gt; & Lt; Script type = "text / javascript" & gt; / * Intel native bridge is available * / var onDeviceReady = function () {// hide splash screen intel.xdk.device.hideSplashScreen (); }; Document.addEventListener ("intel.xdk.device.ready", onDeviceReady, false); & Lt; / Script & gt; & Lt; / Head & gt; & Lt; Body & gt; & Lt ;! - Content goes here - & gt; & Lt; H2 & gt; Hello World & lt; / H2 & gt; & Lt; / Body & gt; & Lt; / Html & gt;   

For more information about requesting AJAX inside Intel XDK,

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -