ASP Ajax Problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • scottrogers
    New Member
    • Jan 2010
    • 1

    #1

    ASP Ajax Problem

    I just inherited this code from someone who developed it back in 02. I need to move the site over to a new IIS Server.

    This script resides on a web form calculator all of the other JavaScript’s work but when I try to call the save function I get a time out error in the browser. Does anyone know why this would not be working on IIS?
    Code:
    function saveData() 
    {
    
    	if(window.XMLHttpRequest) {
    		xml_http = new XMLHttpRequest();
    	} else if(window.ActiveXObject) {
    		xml_http = new ActiveXObject("Microsoft.XMLHTTP");
    	}
    	
    	xml_http.onreadystatechange = show_results;
    	xml_http.open("POST", "goal.php", true);
    	xml_http.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
    	str = getFormElements("frmdata");
    //alert(str);
    	xml_http.send(str);
    	
    }

    Thanks,
    Scott
    Last edited by Frinavale; Feb 17 '10, 03:00 PM. Reason: Please post code in [code] ... [/code] tags. Added code tags.
  • Frinavale
    Recognized Expert Expert
    • Oct 2006
    • 9749

    #2
    I'm not that good with Ajax but that particular ActiveX object that IE uses to make Ajax calls might not be available.

    Try the following to attempt to retrieve the apppropriate ActiveX required for IE to make Ajax calls:
    Code:
    function GetXmlHttp()
    {   /*This function is responsible for creating an HttpRequest object 
          based on the browser that the user is currently using. */
      var xmlHttp = null;            
      try
      {   //Mozilla, Opera, Safari etc.
        xmlHttp=XMLHttpRequest();
      }catch(e)
      {   //Internet Explorer uses ActiveX objects to make Ajax calls.
          //the following are valid versions, here we will loop through 
          //the versions and attempt to create the ActiveX that matches the browser.
        var versionIds = ["Msxml2.XMLHTTP.6.0","Msxml2.XMLHTTP.5.0",
            "Msxml2.XMLHTTP.4.0","Msxml2.XMLHTTP.3.0", 
            "Msxml2.XMLHTTP.2.6","Microsoft.XMLHTTP.1.0", 
            "Microsoft.XMLHTTP.1","Microsoft.XMLHTTP"];
        for(var i=0; i<versionIds.length && xmlHttp == null; i++) 
        {
          xmlHttp = CreateXmlHttp(versionIds[i]);
        }
      }
      return xmlHttp;
    }
    -Frinny

    Comment

    • Curtis Rutland
      Recognized Expert Specialist
      • Apr 2008
      • 3264

      #3
      A timeout error could suggest a problem with the target page. Make sure everything is working as expected on that page.

      Comment

      Working...