Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Dec 2010
    Location
    London
    Posts
    339
    Thanks
    63
    Thanked 11 Times in 11 Posts

    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

  • #2
    Regular Coder
    Join Date
    Dec 2010
    Location
    London
    Posts
    339
    Thanks
    63
    Thanked 11 Times in 11 Posts
    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' />";
    }


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •