SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Guru
    Join Date
    Mar 2004
    Posts
    639
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Script works fine in Firefox, but doesn't work in IE. No error messages.

    Hello guys,

    I have a script, which is works fine in Firefox, but doesn't work in IE. I get no any error messages in IE.

    The problem is when I click links (script calls function that loads some HTML with Ajax), nothing happens in IE. In Firefox script loads photos...

    The Ajax code is standard:

    var AJAXshowPhotos = null;
    if (window.XMLHttpRequest) { AJAXshowPhotos=new XMLHttpRequest(); }else{ AJAXshowPhotos=new ActiveXObject("Microsoft.XMLHTTP"); }

    AJAXshowPhotos.onreadystatechange = function() {
    if (AJAXshowPhotos.readyState==4 || AJAXshowPhotos.readyState=="complete"){
    document.getElementById('photoBox').innerHTML = AJAXshowPhotos.responseText;
    }
    }
    I've checked code like 20 times and everything should work fine. I'm really confused by this.

    Can you look at the sample on this page please (click on "Photo albums", then "Aphrodite's Rock", "Limassol Zoo" that do not work).

    Function that called after user clikcs those links is showPhotoByAlbum();
    Last edited by al9; Jan 31, 2008 at 14:38.

  2. #2
    SitePoint Wizard siteguru's Avatar
    Join Date
    Oct 2002
    Location
    Scotland
    Posts
    3,631
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    This is some code I use to call a PHP file to update a database. (If all goes OK then OK is returned otherwise Not OK is returned). It should be easy to modify for your needs.

    Code:
    function updateSelections (cid, pid, tcb) {
    	var xmlHttp;
    	var resp = '';
    	try {
    		// Firefox, Opera 8.0+, Safari
    		xmlHttp = new XMLHttpRequest();
    	}
    	catch (e) {
    		// Internet Explorer
    		try {
    			xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
    		}
    		catch (e) {
    			try {
    				xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
    			}
    			catch (e) {
    				alert ('Your browser does not handle the photo selection process');
    				return false;
    			}
    		}
    	}
    	xmlHttp.onreadystatechange = function() {
    		if (xmlHttp.readyState == 4) {
    			resp = xmlHttp.responseText; // Response from external file
    			if (resp != 'OK') {
    				alert ('There was a problem recording your photo selection request.');
    			}
    		}
    	}
    
    	// Send the info to the PHP handler page
    	var data = 'updatephototemptable.php?cid=' + cid + '&pid=' + pid + '&tcb=' + tcb;
    
    	xmlHttp.open ("GET",data,true);
    	xmlHttp.send (null);
    }
    Ian Anderson
    www.siteguru.co.uk

  3. #3
    SitePoint Wizard Pepejeria's Avatar
    Join Date
    Jan 2005
    Location
    Too far up north
    Posts
    1,566
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I don't know if you already changed something, but it works fine in IE 6.

  4. #4
    SitePoint Guru
    Join Date
    Mar 2004
    Posts
    639
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Pepejeria, when you click first album it works in IE (you can see photos), but when you try to click another photo album link or another page in the same album (2, 3, 4...), it doesn't work. Are you sure everything works? I mean when you click another albums' links after first one is loaded, does it work?

    siteguru, thanks I will try to check it with your script later. Maybe it's just some IE problem (I've used my Ajax script in like 20-30 scripts, and it always works both in IE and Firefox)

  5. #5
    SitePoint Wizard siteguru's Avatar
    Join Date
    Oct 2002
    Location
    Scotland
    Posts
    3,631
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    My script has been tested and works in IE6/7, FF2, Opera9 and Safari3
    Ian Anderson
    www.siteguru.co.uk

  6. #6
    SitePoint Guru
    Join Date
    Mar 2004
    Posts
    639
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by siteguru View Post
    My script has been tested and works in IE6/7, FF2, Opera9 and Safari3
    The thing is mine works to in IE/FF2, 3/Safari2, in like 20-30 scripts as I said before. Even in this script it works, but just once. I think there is just some conflict that brakes something.

    Your script helped me to find where the problem is. I've moved part that creates Ajax object under function and now it works both in IE and Firefox.

    By the way, unjoined parts of Ajax code works in IE in other scripts, it seems there's just some conflict here.

    Thanks for help guys.


Bookmarks

Posting Permissions

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