Web Analytics Made Easy -
StatCounter Ajax Internet Explorer problem - CodingForum

Announcement

Collapse
No announcement yet.

Ajax Internet Explorer problem

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Ajax Internet Explorer problem

    I implemented a pager using Ajax.
    Now everything works fine in Firefox and Safari.
    Internet Explorer works once but when I click the next page it is not updating anymore.
    This first looks like the infamous caching issue but all those solutions won't work for me.
    I added a timestamp to the url, do post instead of get and put the no-cache into the response header. Nothing of this works so I conclude that there is no caching issue here.
    I'm at a loss now where else to look.
    Here is how I get my request:
    Code:
    function getNewPage(page) {
    
    	//the whole thing with the request comes here
    	var url  = 'https://www.myurl.de/OverviewOrganizations.do'; 
    	var pars = 'page=' + page;
    	pars = uncache(pars);
    	var newPageRequest = new Ajax.Request(
    			url, 
    			{
    				method: 'post', 
    				parameters: pars, 
    				onComplete: showNewPage
    			});
    }
    
    function uncache(newurl){
    	var d = new Date();
    	var time = d.getTime();
    	return newurl + '&time=' + time;
    }
    Is there anything I overlooked?
    Any hint is appreciated!
    Thanks!
    Karola
    Last edited by kschaeuble; Oct 10, 2006, 06:48 AM.

  • #2
    Hasn't anybody any idea?
    I made some additional tests and the xml response seems to be correct, but the page is still not updated. As the first time the request is made everything works fine I assume the code is alright.
    So it really looks like the caching problem but neither of the solutions worked. Are there any further things I can do except the things I wrote above?
    Oh I forgot to say, I use prototype.js which explains the request code above. And my IE is version 6. The server is a Tomcat 5.5. Don't know if any of this information will help. *sigh*
    I post my other code too, that updates the page with the new data. I always use innerHTML.
    Code:
    function showNewPage(originalRequest) {
    	//this function translates the xml response into the new html
    	if (document.implementation && document.implementation.createDocument){
    	xmlDoc = originalRequest.responseXML;
    	} else if (window.ActiveXObject){
    	var testandoAppend = document.createElement('xml');
    	testandoAppend.setAttribute('innerHTML',originalRequest.responseText);
    	testandoAppend.setAttribute('id','returnedXML');
    	document.body.appendChild(testandoAppend);
    	document.getElementById('returnedXML').innerHTML = originalRequest.responseText;
    	xmlDoc = document.getElementById('returnedXML');
    	}
    	alert(document.getElementById('returnedXML').innerHTML); //this shows the right data
    	/* The following code generates the html for the new pager. */
    	var pagerNode   = xmlDoc.getElementsByTagName('pager')[0];
    	var curPage     = pagerNode.getAttribute('page');
    	var pages				= pagerNode.getAttribute('pages');
    	var pagerHtml		= "";
    	
    	if(curPage != 1) {
    		pagerHtml = "<a href='javascript:getNewPage(" + (parseInt(curPage)-1) + ")'><img src='images/arrows/left.gif' style='border:none;' /></a>";
    	}
    	for (var i = 1; i <= pages; i++){
    		if(i == curPage) pagerHtml += i;
    		else pagerHtml += "<a href='javascript:getNewPage(" + i + ")'>" + i + "</a>";
    	}
    	if(curPage != pages) {
    		pagerHtml += "<a href='javascript:getNewPage(" + (parseInt(curPage)+1) + ")'><img src='images/arrows/right.gif' style='border:none;' /></a>";
    	}
    	document.getElementsByClassName('pager')[0].getElementsByTagName('td')[0].innerHTML = pagerHtml;
    	/* End pager */
    	
    	/* The following code generates the html for the new overview table. 
    	It has to be generated dynamically to match all overview pages. */
    	var organizationNodes = xmlDoc.getElementsByTagName('organization');
    	var overviewHtml 			= "";
    	var overviewTableTds  = document.getElementsByClassName('overview')[0].getElementsByTagName('td');
    	
    	for(var i=0;i<organizationNodes.length;i++){
    		var organization = organizationNodes[i];
    		var orgname 		 = "<a href='/pmt/EditOrganization.do?actorID=" + organization.getAttribute('actorId') + "'>" + organization.getAttribute('name') + "</a>";
    		var shortname 	 = organization.getAttribute('shortname');
    		var address 		 = organization.getAttribute('street') + " " + organization.getAttribute('housenumber') + "<br/>" + organization.getAttribute('postalcode') + " " + organization.getAttribute('town');
    		var country 		 = organization.getAttribute('country');
    		var website 		 = "<a href='http://" + organization.getAttribute('website') + "' target='new'>" + organization.getAttribute('website') + "</a>";
    		var email 			 = "<a href='mailto:" + organization.getAttribute('email') + "'>" + organization.getAttribute('email') + "</a>";
    		var actionLinks  = "<span class='hyperlink'>[<a href='/pmt/ProcessActor.do?method=inactivateOrganization&amp;actorID=" + organization.getAttribute('actorId') + "' title='Organisation inaktivieren'>-</a>]</span>";
    
    		overviewTableTds[i*7].innerHTML = orgname;
    		overviewTableTds[(i*7)+1].innerHTML = shortname;
    		overviewTableTds[(i*7)+2].innerHTML = address;
    		overviewTableTds[(i*7)+3].innerHTML = country;
    		overviewTableTds[(i*7)+4].innerHTML = website;
    		overviewTableTds[(i*7)+5].innerHTML = email;
    		overviewTableTds[(i*7)+6].innerHTML = actionLinks;
    	}
    	/*End overview*/
    }

    Comment


    • #3
      I use this code, over and over and over again, without any problems, in IE and FF. Why not give it a try and see if it will help.

      Code:
      var AdminResponse = "";
      
      function parseSettings(){
      
      	**** Your parsing code here *******
      
      }
      
      function obtainSettings(){
      
      		var AdminRequest = window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest();   
      		AdminRequest.onreadystatechange = function()
      			{
      			 if (AdminRequest.readyState == 4)
      				{
      			 	 if (AdminRequest.status == 200)
      					{
      				 	 AdminResponse = AdminRequest.responseXML;
      				 	 parseSettings();
      					}
      			 	 else 	{
      					 alert('Error Admin File '+ AdminRequest.statusText);
      					}
      				}
      			}
      		var forceGET = "?n="+ parseInt(Math.random()*999999999);
      		AdminRequest.open("GET", "TrafficFiles/Admin.xml"+forceGET, true);
      		AdminRequest.send(null); 
      }

      Comment


      • #4
        Wahoo! *dance*
        I finally found the problem!
        It was not in the request code but in how I obtain the XML from the request, which is different for the IE. This comes from copying code from others and not totally understand it. *shame*
        The problem is, that I appended the responseText to the document, so the XML was to be found within the page. But I never removed it after using the data. So that's why it still found the old data and the site showed no difference.
        Thanks for listening and sharing!
        Karola

        Comment

        Working...
        X