Hey everyone

!
I've been programming for some years now, but only recently have i started adopting the
AJAX techniques. Right now i have implemented an
AJAX based login system and i want to implement a "menuLoader" of some sort, so that each time a user logins it will also refresh the menu. Usually this wouldn't be much of a problem but with
AJAX it's different
- Code: Select all
function getPermissions()
{ // only get a seed if we're not logged in and we don't already have one
if (!hasPerm && http_menu) {
try{
// open up the path
http_menu.open('GET', MENU_PREFIX + 'task=getperm', true);
http_menu.onreadystatechange = function(){
handleHttpGetPermissions();};
http_menu.send(null);
} catch(e){
perm_id = 'Could not connect to server.';
}
}
else
perm_id = 'Could not create the HttpXml object';
}
function handleHttpGetPermissions()
{
// if there hasn't been any errors
if (http_menu.readyState == NORMAL_STATE_MENU) {
// split by the divider |
results_menu = http_menu.responseText.split('|');
if(results_menu[0] == true){
// perm is the first element
perm_id = results_menu[1];
// now we have the perm
hasPerm = true;
}
else if(results_menu[0] == false){
perm_id = 'results_menu[1];
}
else{
perm_id = results_menu[0];
}
}
else{
perm_id = http_menu.readyState;
}
}
The actual object is loaded in a global variable.
- Code: Select all
var http_menu = getHTTPObject();
This uses a function from a seperate file I use just to create the XmlHttpRequest Object. This work's fine in my login system, so i don't see any reasons for it not to work in this situation, but the fact is that the readyState won't go pass 1!! The loadMenu function is called at a eventlistener which i use to call the login funtion so there shouldn't be a problem there...
Can anyone tell me what's wrong here?
PS: In this code the perm_id variable is suposed to be used to hold the permission level of the user but i ended up using it to transport other messages just to check out what's happening so don't be offended by it
