Go Back   CodingForums.com > :: Client side development > JavaScript programming > Ajax and Design

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 04-03-2012, 10:24 PM   PM User | #1
paddyfields
Regular Coder

 
Join Date: Dec 2010
Location: London
Posts: 280
Thanks: 60
Thanked 11 Times in 11 Posts
paddyfields is an unknown quantity at this point
showing a 'loading' gif.

Hi there. I've tried searching for this in the archive but can't find anything that works. Slowly getting used to AJAX though my main goal works!!!

I'd like to show a little 'loading' image while the request is being retrieved from the server.

This is my Code... (with bold where I think it should go)

Code:
//Browser Support Code
function ajaxUnSaveEvent(){
	var ajaxRequest;  // The variable that makes Ajax possible!
	
	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
	}
	// Create a function that will receive data sent from the server
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
			document.getElementById("myDiv").innerHTML=ajaxRequest.responseText;
		}
             else{document.getElementById("myDiv").innerHTML=image info}
	}
	var memberid = <?php echo $memberid; ?>;
	var gigid = <?php echo $gigid; ?>;
	var queryString = "?mem=" + memberid + "&gig=" + gigid;
	ajaxRequest.open("GET", "ajaxforgetgig.php" + queryString, true);
	ajaxRequest.send(null); 
}

</script>
Is this how it works? Also, what would I put instead of 'image info'?

If you could help me out I would be extremely greatful. I've been trying this all night with various methods but no luck!

Many thanks
paddyfields is offline   Reply With Quote
Old 04-03-2012, 10:48 PM   PM User | #2
paddyfields
Regular Coder

 
Join Date: Dec 2010
Location: London
Posts: 280
Thanks: 60
Thanked 11 Times in 11 Posts
paddyfields is an unknown quantity at this point
Sod's law, I get it working soon after posting.

For anyone who needs to know, where I have the text in bold simply add the code below;

Code:
else
{
document.getElementById("myDiv").innerHTML = "<img src='Images/icons/loading.gif' />";
}
paddyfields is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

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

Forum Jump


All times are GMT +1. The time now is 06:22 PM.


Advertisement
Log in to turn off these ads.