- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
My code works fine in the simulator, but when I push to the test app on my phone, I get an error when I do an AJAX call to me server.
// login and receive token and a list of tickets
function login(){
var userID=$("#userID").val();
var userPW=$("#userPW").val();
if( !userID || !userPW){
alertify.alert("Please enter user and password");
return;
}
var dataString="userID="+escape(userID)+"&userPW="+escape(userPW);
spinner(1); // turn on "waiting" animation
$.ajax({
url: "http://myDomain.com/cgi/mlogin.exe",
dataType: "json",
data: dataString,
error: ajaxError,
success: function(json){
if(json.error !== "0"){
spinner(0);
alertify.alert("ERROR "+json.error);
return;
}
setToken(json.token);
$("#actionDiv").load("stubs/logonReturn.html");
setTimeout(function(){
var tlist=$("#ticketList");
var ticket="";
var custID="";
for(var i=0;i<=json.tickets.length-1;i++){
ticket=json.tickets.ticket;
custID=json.tickets.custID;
tlist.append( $("<option class='tlOption'></option>").attr("value", ticket ).text( ticket+" "+custID ) );
}
spinner(0);
},1000);
}
});
}
// generic ajax error handler
function ajaxError(request, type, errorThrown) {
var message = "There was an error with the AJAX request.\n";
switch (type) {
case 'timeout':
message += "The request timed out.";
break;
case 'notmodified':
message += "The request was not modified but was not retrieved from the cache.";
break;
case 'parsererror':
message += "XML/Json format is bad.";
break;
default:
try{
message += "HTTP Error (" + request.status + " " + request.statusText + ").";
}catch(e){
return;
}
}
message += "<br>";
alertify.alert(message);
spinner(0);
}
The error is 0; eg, no error.
why?
- Tags:
- HTML5
- Intel® XDK
Link Copied
1 Reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
the solution was to use JSONP, not JSON for my CGI request
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page