SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Feb 2005
    Posts
    59
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    IE executes JavaScript before AJAX updater runs

    Even though the AJAX call is after I hide the DIV, by using an alert I was able to verify the IE is evaluating the JavaScript before running the AJAX update to pull in the new content. FF works fine.

    Here's the calling page:
    Code:
    <script>
      function getPrices(id,p1){
      		p2 = p1;
    		id2 = id;
      	var setID = id;
    	var setPath = 'content.html';
       
    	if (document.getElementsByClassName('dwp_2')){
    			idToChange = document.getElementsByClassName('dwp_2')
    			for(i=0; i <idToChange.length;i++)
    			{ 
    				new Effect.Fade(idToChange[i],{duration: .2,queue:'front'});
    				idToChange[i].className='';
    			}
    		}
    	
    	new Ajax.Updater(setID,setPath, { // URL for next <IMG> tag 
    		asynchronous: true,
    		evalScripts:true,
    		method:'get', 
    		onSuccess: showAjax() 
    		})
    			 
    		
      	function showAjax() { 
    		new Effect.Appear(setID,{duration: .2,afterFinish: setNewID,queue:'end'});
    		}
    	function setNewID() {
    		document.getElementById(setID).className='dwp_2';
    	}
      	}
      
      </script>
    
    </head>
    
    <body>
    <a href="#" onclick="getPrices('updateMe','395');">Make It</a>
    <div id="updateMe" style="display:none;"></div>
    <p>&nbsp;</p>
    <a href="#" onclick="getPrices('updateMe2','895');">Make It</a>
    <div id="updateMe2" style="display:none;"></div>
    And here's the AJAX content:
    Code:
    <script>
    p3 = p2 - 0;
    
    document.getElementById('a1').innerHTML = '$'+p3;
    document.getElementById('a2').innerHTML = '$'+(p3+100);
    document.getElementById('a3').innerHTML = '$'+(p3+150);
    
    
    alert(p3);
    
    </script>
    a1
    	<div id="a1"></div>
    a2
    	<div id="a2"></div>
    a3
    	<div id="a3"></div>
    
    
    <a id="closeLink" href="#" onclick="new Effect.toggle(id2,'appear',{duration: .2}); return false;">Click To Close</a>
    Do I need to remove the previous AJAX content from the DOM or something?

  2. #2
    SitePoint Wizard gRoberts's Avatar
    Join Date
    Oct 2004
    Location
    Birtley, UK
    Posts
    2,439
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    could you try replacing

    onSuccess: showAjax();

    with

    onSuccess: showAjax;

    and let me know what happens?


  3. #3
    SitePoint Enthusiast
    Join Date
    Feb 2005
    Posts
    59
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by gRoberts View Post
    could you try replacing

    onSuccess: showAjax();

    with

    onSuccess: showAjax;

    and let me know what happens?
    Still the same behavior in IE, and remains functional in FF


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
  •