[advanced search]
 

Go Back   NamePros.com > Discussion > Web Design & Development > Programming

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.


Closed Thread
 
LinkBack Thread Tools
Old 07-14-2008, 03:58 PM   #1 (permalink)
NamePros Regular
 
omegapandor's Avatar
 
Join Date: May 2008
Posts: 240
611.95 NP$ (Donate)

omegapandor will become famous soon enoughomegapandor will become famous soon enough


More than one ajax request?

I'm just learning about the XmlHttpRequest object. I have a basic demonstration for myself built, but I can only use it once. After pressing the "submit" button, I have to exit out of firefox before trying it again. If I press the button more than once, nothing happens.

I think I need to restart the object for accepting requests at the end of my code or something. . .but I don't know how.

Pls. . .helps. . .

Code:
createobjectandstuff()
{

req.onreadystatechange = function()
		{ 
			document.ajax.txt.value="Attacking...";
			if(req.readyState == 4)
			{
				if(req.status == 200)
				{
					document.ajax.txt.value=req.responseText;	
				}	
				else	
				{
					document.ajax.txt.value="Error: returned status code " + req.status + " " + req.statusText;
				}	
			} 
		}; 
		req.open("GET", "fileiwantoget.php", true); 
		req.send(null);
	}
__________________
Are you tired of viruses and popups? Use Firefox!
omegapandor is offline  
Old 07-14-2008, 04:52 PM   #2 (permalink)
Senior Member
 
nasaboy007's Avatar
 
Join Date: Jul 2005
Location: NJ
Posts: 1,112
1,454.30 NP$ (Donate)

nasaboy007 has much to be proud ofnasaboy007 has much to be proud ofnasaboy007 has much to be proud ofnasaboy007 has much to be proud ofnasaboy007 has much to be proud ofnasaboy007 has much to be proud ofnasaboy007 has much to be proud ofnasaboy007 has much to be proud of


i'm no ajax expert, but whenever i've used it i've always called the function with onkeyup, onchange, onblur, or onfocus.

if you look on w3schools.com they have the basic framework that almost all ajax scripts need (which i don't see in your code, but then again you could be doing some other method i don't know about).
nasaboy007 is offline  
Old 07-14-2008, 05:31 PM   #3 (permalink)
NamePros Regular
 
omegapandor's Avatar
 
Join Date: May 2008
Posts: 240
611.95 NP$ (Donate)

omegapandor will become famous soon enoughomegapandor will become famous soon enough


I just realized that my submit button creates the object every time. I assume this is bad and has something to do with the problem.
__________________
Are you tired of viruses and popups? Use Firefox!
omegapandor is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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


Site Sponsors
Advertise your business at NamePros

All times are GMT -7. The time now is 02:01 PM.


Powered by: vBulletin® Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0
Template-Modifications by TMS
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios

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 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85