I am developing a Blackberry web application and I am having problems with the AJAX request I make on the server. I learn HTML / Javascript / AJAX "on the fly", so I apologize for the beginning errors. Basically, formatted HTTP requests go to a server, which returns the JSON objects that I use in the application. I use AJAX for queries without any frameworks. Most requests do not have to be authenticated, and they are returned in order. However, to access part of the directory on the server, the username and password are encoded and sent as a header using XMLHTTPRequest. when I try to add a header, the request is sent, but I never get anything. The readyState property has a value of 1, but never goes beyond that. I know the server works fine because I did the same for the iPhone and it worked.
Here is the relevant code:
function grabFromServer(httpRequest){ httpConnection = new XMLHttpRequest(); var me = this; httpConnection.onreadystatechange=function(){ alert(httpConnection.readyState); if(httpConnection.readyState==4){ me.processResponseText(httpConnection.responseText); } }; httpConnection.open("GET", httpRequest,true); if(this.request == "company" || this.request == "property" || this.request == "individual"){ var authorized = this.checkCredentials(); if(!authorized){
}
source share