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 5 of 5
  1. #1
    Senior Coder BarrMan's Avatar
    Join Date
    Feb 2005
    Location
    Israel.
    Posts
    1,644
    Thanks
    69
    Thanked 83 Times in 82 Posts

    Getting page 404 error

    Hi. I'm trying to request an ASP page that works fine to my page but it says that it doesn't find the page although it's on the same directory of the file.
    Here's my code:
    Code:
    function update(obj)
    {
    	var xmlHttp = GetXml();
    	var url="ajax.asp";
    	url=url+"lang="+obj.options[obj.selectedIndex].value;
    	//url=url+"&sid="+Math.random();
    	xmlHttp.onreadystatechange=function(){
    	//
    		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
    		{
    			//if(xmlHttp.status == 200)
    				document.getElementById("txt").value = xmlHttp.responseText;
    			//else
    			//	alert("xmlHttp.status = " + xmlHttp.status);
    		}
    	} ;
    	xmlHttp.open("GET",url,true);
    	xmlHttp.send(null);
    }
    
    function GetXml()
    {
    var xmlHttp=null;
    try
     {
     xmlHttp=new XMLHttpRequest();
     }
    catch (e)
     {
     try
      {
      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      }
     catch (e)
      {
      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
     }
    return xmlHttp;
    }
    Ajax.asp [All Commented = Empty sheet]
    Code:
    <%'@Language="VBScript"%>
    <%
    'Dim strLang
    'Dim Conn
    'Dim Rs
    'Dim SQL
    'strLang = Request.QueryString("lang")
    'Set Conn = Server.CreateObject("ADODB.Connection")
    'Set Rs = Server.CreateObject("ADODB.Recordset")
    'Conn.Open = "PROVIDER=Microsoft.Jet.Oledb.4.0; Data Source='" & Server.MapPath("../db.mdb") & "'"
    'SQL = "SELECT * FROM contents WHERE page = 'index' AND lang = '" & strLang & "'"
    'Rs.Open SQL,Conn
    'Response.Write Rs("content")
    'Rs.Close
    'Set Rs = Nothing
    'Conn.Close
    'Set Conn = Nothing
    %>

  • #2
    New Coder
    Join Date
    Aug 2007
    Posts
    33
    Thanks
    7
    Thanked 0 Times in 0 Posts
    try putting
    Code:
          var status ="";
          var statusText ="";
          try{ status = xmlHttp.status;}catch(e){}
          try{ statusText = xmlHttp.statusText}catch(e){}
    before onreadystatechange

  • #3
    Smokes a Lot
    Join Date
    Jul 2003
    Location
    CA, USA
    Posts
    1,594
    Thanks
    5
    Thanked 20 Times in 20 Posts
    Put the full url in your path to the file, does that change anything?
    Helping to build a bigger box. - Adam Matthews

  • #4
    Regular Coder
    Join Date
    Feb 2005
    Posts
    679
    Thanks
    0
    Thanked 16 Times in 15 Posts
    You are getting the 404 error because you are not properly appending the query string to the URL , ie '?'
    Code:
    url=url+"?lang="+obj.options[obj.selectedIndex].value;
    
    or with +=
    
    url+="?lang="+obj.options[obj.selectedIndex].value;

  • #5
    Senior Coder BarrMan's Avatar
    Join Date
    Feb 2005
    Location
    Israel.
    Posts
    1,644
    Thanks
    69
    Thanked 83 Times in 82 Posts
    Thanks! I solved it! The problem with with the missing question mark and afterwards with my query which I then fixed.


  •  

    Posting Permissions

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