Dynadot Aftermarket: discover domain gems worth investing in. Visit our aftermarket.

More than one ajax request?

Namecheap AuctionsNamecheap Auctions
Spacemail by SpaceshipSpacemail by Spaceship
SpaceshipSpaceship
Watch

omegapandor

Established Member
Impact
4
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);
	}
 
0
Close
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
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).
 
0
Close
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.
 
0
Close
Appraise.net

We're social

Escrow.com
Spaceship
Domain Recover
CryptoExchange.com

NamePros updates

Member card: see how many threads a member started
The member card now shows a Threads number, right after Posts. The member card is the box that opens when you point at a name. Profile...
AIVikings
Catchy
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back