Problems with XmlHttpRequest Object: readystate won't go past 1

This is a discussion on "Problems with XmlHttpRequest Object: readystate won't go past 1" within the JavaScript Forum section. This forum, and the thread "Problems with XmlHttpRequest Object: readystate won't go past 1 are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > JavaScript Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Jan 12th, 2008, 16:44
New Member
Join Date: Jan 2008
Location: Madrid, Spain
Age: 22
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Exclamation Problems with XmlHttpRequest Object: readystate won't go past 1

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
Reply With Quote

  #2 (permalink)  
Old Jan 13th, 2008, 14:18
spinal007's Avatar
Moderator
Join Date: Mar 2004
Location: Good Ol'London
Age: 22
Posts: 1,612
Blog Entries: 1
Thanks: 0
Thanked 2 Times in 2 Posts
Send a message via ICQ to spinal007 Send a message via MSN to spinal007 Send a message via Yahoo to spinal007 Send a message via Skype™ to spinal007
Re: Problems with XmlHttpRequest Object: readystate won't go past 1

well, readyState can be 0:uninitialised, 1:loading, 2:loaded, 3:interactive, 4:complete.
If you're not going past 1, then check the URL of the request (ie.: MENU_PREFIX)

I recommend you test Ajax apps in Firefox with Firebug.
Last Blog Entry: Random String in Javascript (Apr 21st, 2008)
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] XmlHttpRequest not working properly djeyewater JavaScript Forum 3 Jan 31st, 2008 20:33
xmlhttprequest, firefox hangs on 3rd call simonB2007 JavaScript Forum 0 Jun 12th, 2007 15:26
<object> mayhem :) BigWings Web Page Design 15 Dec 12th, 2006 20:40
Open pop up window onCLick Getting past XP popup stopper? Andy K JavaScript Forum 3 May 22nd, 2005 21:04


All times are GMT. The time now is 11:29.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43