I've an adobe air app that I've been building using Dreamweaver CS5 as my IDE. When I preview the application everything works perfectly. When I create the ap开发者_JAVA百科p and try and run it the first XMLHttpRequest I run fails. I'm thinking it is a security issue, but I've not clue.
I get the 'invalid' password message every time because the domainCOM.status is returning a status of 0.
UPDATE: I installed an app to watch the XMLHttpRequest and it says that I'm getting a status of 200 and I can see the correct XML being returned. This menas that adobe air is somehow making the status of 200 into a 0.
UPDATE2: If I run it in preview I get
readyState 2, status 200 readyState 3, status 200 readyState 3, status 200 readyState 4, status 200
but if I run it in the compiled version I only get
readyState 4, status 0
Seems like it's not doing anything but I can see the actual XHR making the call and returning using Fiddler2.
Very weird.
Any help / thoughts would be appreciated. Here's the code snippet:
var url = "http://open-api.domain.com/authentication.getUserToken.domain";
var vars = "v=3&appKey="+appKey+"&email="+email+"&password="+password;
var domainCOM = new XMLHttpRequest();
domainCOM.open("POST", url, true);
domainCOM.setRequestHeader ("Content-type", "application/x-www-form-urlencoded");
domainCOM.setRequestHeader ("Content-length", vars.length);
domainCOM.setRequestHeader ("Connection", "close");
domainCOM.onreadystatechange = function() {
if (domainCOM.readyState == done) {
if (domainCOM.status == ok) {
if (domainCOM.responseText) {
//do some stuff
}
else {
window.alert('unknown error in authenticationGetUserToken.');
}
}
else {
window.alert('Password / Userid combination is not valid. Please correct and try again.');
}
}
};
domainCOM.send(vars);
return;
Thanks, Casey
Whenever I get a status code 0
in a web browser, it usually means I'm making a cross-domain request and the browser is simply dropping the request. Are your JS files being loaded in the application sandbox? Though I've not tried it yet, Air allows [cross-domain AJAX requests] in the application sandbox, but has sharply limited the cross-domain abilities of pages loaded off web servers.
精彩评论