- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have an ajax call in my app that works fine in the emulator and on the emulator app, but when I make an APK file, it hangs.
The app collects the user's user id and password, and passes it to the web server.
The web server returns a token and some other user-specific data.
I know the request is hitting the server. The problem seems to lie in parsing the returning json?
I also know the json is good. How do even begin troubleshooting this?
$("#spinner").show();
var uID=$("#userID").val();
var uPW=$("#userPW").val();
var dataString="userID="+uID+"&userPW="+uPW;
$.getJSON("http://mydomain.com/cgi/mlogin.exe?"+dataString, function(json){
if(json.error!=="0"){
$("#loginResult").html(json.error);
$("#spinner").hide();
return;
}
$("#loginResult").html("logged in");
$("#loginResult").css("color","#ffff00");
$("#loginResult").css("background","#000");
$("#spinner").hide();
$("#loginButton").html("log off");
$("#ticketData").html("tickets and stuff");
intel.xdk.cache.setCookie("token",json.token,7);
var t="";
for(var i=0;i<=json.tickets.length-1;i++){
t+="<div class='tRow'>";
t+="<div class='tNumber'>";
t+=json.tickets.ticket;
t+="</div>";
t+="<div class='tProblem'>";
t+=json.tickets.problem;
t+="</div>";
t+="<div class='tCustID'>";
t+=json.tickets.custID;
t+="</div>";
t+="<div class='clr'></div>";
t+="</div>";
}
$("#ticketData").html(t);
});
- Tags:
- HTML5
- Intel® XDK
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am not expert but i think don't use intel.xdk.cache.setCookie or any intel.xdk function.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Try to show the result using JSON.stringfy(). Maybe you can see something wrong.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Use the Debug tab, not the Emulate tab to debug this issue. If that does not work, then try using remote CDT with a built app. See this page for lots of debug options: https://software.intel.com/en-us/xdk/docs/intel-xdk-debug-and-test-overview
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes it seems the issue was with intel.xdk.cache.setCookie
What is the better way to set/retrieve a cookie?
I'm going to try using just plain javaScript.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Use Crosswalk on Android to insure that "just plain JavaScript" works. :) You'll get your best results that way. The Debug tab uses Crosswalk.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This is how I ended up making it work.
I set a variable to a windows object instead of a cookie
in my login function
setToken(json.token);
then when I need it I just use
var tkn=getToken();
and the functions look like this:
// set token
function setToken(v){
window.token = v;
return;
}
// retrieve token
function getToken(){
return window.token;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'm getting my "testing" phone set up to use the DEBUG tab.
That's way better than email apk builds to myself.
thanks
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page