Go Back   CodingForums.com > :: Client side development > JavaScript programming > Ajax and Design

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 10-11-2012, 09:08 PM   PM User | #1
surreal5335
Regular Coder

 
Join Date: May 2008
Posts: 446
Thanks: 23
Thanked 5 Times in 5 Posts
surreal5335 is an unknown quantity at this point
getting xmlhttp.status 404

I am trying to get a connection to my php file and currently I keep getting a 404 error.

Code:
function loadXMLDoc(id)
{
var xmlhttp;
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
      alert('xmlhttp.readyState: '+xmlhttp.readyState+' xmlhttp.status: '+xmlhttp.status);
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("left_column").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","get_ajax.php?postid="+id,true);
xmlhttp.send();
}
I have the get_ajax.php file in the same directory as my js file that is handling my ajax call

What am I missing here?

Thanks alot
surreal5335 is offline   Reply With Quote
Old 10-11-2012, 09:13 PM   PM User | #2
patryk
Regular Coder

 
patryk's Avatar
 
Join Date: Oct 2012
Location: /dev/couch
Posts: 395
Thanks: 2
Thanked 64 Times in 64 Posts
patryk is on a distinguished road
404 means there's no such document.
maybe wrong addres?
patryk is offline   Reply With Quote
Old 10-11-2012, 11:46 PM   PM User | #3
surreal5335
Regular Coder

 
Join Date: May 2008
Posts: 446
Thanks: 23
Thanked 5 Times in 5 Posts
surreal5335 is an unknown quantity at this point
thanks for the reply,

I know what 404 means, just trying to understand why the file is not being found. I guess I could hard code the entire url to the php file to see if it finds it then
surreal5335 is offline   Reply With Quote
Old 10-12-2012, 07:44 AM   PM User | #4
Dormilich
Senior Coder

 
Dormilich's Avatar
 
Join Date: Jan 2010
Location: Behind the Wall
Posts: 2,907
Thanks: 10
Thanked 293 Times in 289 Posts
Dormilich is on a distinguished road
is the HTML page in the same directory as its JS file?
__________________
please post your code wrapped in [CODE] [/CODE] tags
Dormilich is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 04:07 AM.


Advertisement
Log in to turn off these ads.