- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
I'm newbie at Intel XDK and this is my first post here, so I'm sorry if my question is out of logic...
I'm starting to build an web app with Intel XDK. For the loggin purpose I've made an Ajax request to a php script.
Questions:
1º - My request is working fine when I go to the published website, however, nothing happens on the emulator. Is that normal? (I've done with jquery ajax call, and with XMLHttpRequest. both gave same result...)
2º - I've seen examples with "AppMobi.device.getRemoteData" and "intel.xdk.device.getRemoteDataWithID". Do this examples only work with cordova?
Thanks in advance...
- Tags:
- HTML5
- Intel® XDK
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi José,
In the XDK app you keep the same url to call the php login?
var url = 'php/autentica.php?AUTT='+base64.encode( JSON.stringify(AUTT));
The app is not hosted on your server, could be this the issue?
Regards
Diego
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi José,
Could you post the php ajax request?
Did you check in the Emulate tab the debug option for errors?
Regards,
Diego
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello Diego,
Thanks for your repply.
The request is made like:
var AUTT = { tarefa: 'login', login: document.getElementsByName('auttUsr')[0].value, pass: document.getElementsByName('auttPwd')[0].value, lembra: document.getElementsByName('auttRem')[0].checked*1, cookie: (document.cookie.search('sigit')>=0 ? document.cookie.split('sigit=')[1] : false), }; var url = 'php/autentica.php?AUTT='+base64.encode( JSON.stringify(AUTT)); $.ajax({type: "GET", url: url, beforeSend: function () {}, // To implement when loading; complete: function () {}, // To implement after loading; success: function(status) { var resposta = JSON.parse(status); // Functions used on sucess! }, error: function(jqXHR, exception) { var mess=''; if (jqXHR.status === 0) { mess="Não se encontra ligado.\n Verifique a ligação de rede."; } else if (jqXHR.status == 404) { mess="A página requerida não foi encontrada. [404]"; } else if (jqXHR.status == 500) { mess="Erro interno de servidor [500]."; } else if (exception === 'parsererror') { mess="O pedido de análise JSON retornou um erro."; } else if (exception === 'timeout') { mess="Erro de tempo excedido."; } else if (exception === 'abort') { mess="O pedido Ajax foi abortado."; } else { mess="Falha a efectuar o login. Detalhes: \n" + jqXHR.responseText; } var opts={ message: mess, position:"tc", delay:2000, autoClose:true, type:"error" }; $.afui.toast(opts); } });
If I debug, I'll get the error:
Uncaught SyntaxError: Unexpected token < autt.js:53
$.ajax.success autt.js:53
j jquery.min.js:2
k.fireWith jquery.min.js:2
x jquery.min.js:4
(anonymous function) jquery.min.js:4
The autt.js file is where I have the ajax call, and line 53 is where I have "var resposta = JSON.parse(status);".
The jquery version is 2.1.4.
Strangely, this works fine when I use chrome or IE from a computer accessing the server, however it doesn't in the Intel XDK emulator...
One other strange thing is that I inserted an alert, with the var status immediately before line 53.
On the computer with chrome, IE, etc. it gives an alert with the answer.
On the emulator it gives an alert with text of the php file!!! is it possible it is reading the file instead of executing the file?!?
Best regards,
José Mendes
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi José,
In the XDK app you keep the same url to call the php login?
var url = 'php/autentica.php?AUTT='+base64.encode( JSON.stringify(AUTT));
The app is not hosted on your server, could be this the issue?
Regards
Diego
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
OK!
I've solved the problem without understanding it properly:
I didn't put the server in the url.
It works fine in production but not in emulation!...
changing from "php/autentica.php" to "http://server_x/php/autentica.php" will make it work in production and in emulation!
If someone will help me understand why, I would aprecciate...
Thanks in advance,
José Mendes
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Sorry, I answered before seeing your answer...
Now I understand!
You are right, the app it's not in the same server.
I feel stupid not to see it immediately...
Thanks for the help.
Best regards,
José Mendes
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page