Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: XMLHttpRequest returns 404 on Php files

  1. #1
    Join Date
    Sep 2010
    Posts
    10
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default XMLHttpRequest returns 404 on Php files

    If you want to recreate the error go here and click on the contact us link in the horizontal menu under the masthead. In the interests of the site not being totally non-functional I have removed the query string entirely from all the other other links and replaced them with individual files for each one - except for the link to the contact form. I do need a generic solution for some of the functionality which the menu.swf file uses. Plus it used to be nice and elegant. This all used to work...I am mystified at how I managed to break it.

    I replaced my original XMLHttpreq routine with an ajax one and now I can load html, and php... but not if the php has a query string. Any ideas why? Javascript and Php code are in responses below.
    Last edited by urbanvintner; 09-25-2010 at 12:10 AM.

  2. #2
    Join Date
    May 2007
    Location
    Boston,ma
    Posts
    2,127
    Thanks
    173
    Thanked 207 Times in 205 Posts

    Default

    Try alerting the variable url to see what it is being set as, or post a link/whole code.
    Corrections to my coding/thoughts welcome.

  3. #3
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    What's the syntax of your jQuery ajax? What's the PHP code look like on the page that gets loaded with the query string? I'm assuming it has includes or requires on it, perhaps they are the 404 error. If you haven't already, make the include(s)/require(s) on bloader.php use the absolute path.

    Later:

    Oh, I see the code now, you should probably not set a timeout:

    Code:
          $.ajax({
            url: url,
            timeout:5000,
            success: function(data){
              msg.html('');
              container.
              html(data)
    	  if(url=="event.html"){
    		gotoframe(99);	
    		thisMovie("menu").HTMLtojava();
    	  }
              dhtmlHistory.add(url, container.html);
            },
            error: function( . . .
    But I don't think that's it, once it gets the 404, it is completing. I put my money on the paths for any included files on bloader.php.
    Last edited by jscheuer1; 09-24-2010 at 02:53 PM. Reason: add info
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  4. The Following User Says Thank You to jscheuer1 For This Useful Post:

    urbanvintner (09-25-2010)

  5. #4
    Join Date
    Sep 2010
    Posts
    10
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default Thanks John

    I tried your suggestion of absolute path. URL file-access is disabled though so that results in a PHP error. Also I am using a relative path on the php files without query strings. In the interests of the site not being totally non-functional I have removed the query string entirely now and replaced them with individual files for each link - except for the link to the contact form. You can click on that if you want to recreate this error. I do need a generic solution for some of the functionality which the menu.swf file uses. Plus it used to be nice and elegant. This all used to work...I am mystified at how I managed to break it.

    My Javascript is attached. Here is the PHP I am using. This is bloader.php which Ajax comes back with a 404 on
    Code:
    <?php
    header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
    header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past
    ?>
    <?PHP require_once('blog/wp-blog-header.php');?>
    <?PHP 
     $name = $_GET['name'];
    query_posts('pagename='.$name);while (have_posts()): the_post(); ?>
    <h2><?php the_title(); ?></h2>
    <?php the_content(''); ?>
    <?php endwhile; ?>
    And here is about.php which works, and is exactly the same. It just doesn't require a query string.
    Code:
    <?PHP require_once('blog/wp-blog-header.php'); ?>
    <?php
    header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
    header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past
    ?>
    <?PHP $name = "about";
    query_posts('pagename='.$name);while (have_posts()): the_post(); ?>
    <h2><?php the_title(); ?></h2>
    <?php the_content(''); ?>
    <?php endwhile; ?>

  6. #5
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Quote Originally Posted by urbanvintner View Post
    I tried your suggestion of absolute path. URL file-access is disabled though so that results in a PHP error.
    That's unfortunate. From your PHP code it looks as though more of that sort of thing may be happening on the required files, these should be network paths. And/or that there may be functions on the required file that use paths, these should also be network paths.

    The problem is, if you include a file on a page, its relative paths are relative to the page it's included on. However, if it's part of an AJAX request, there may be no relative path that would be correct.

    If you cannot use the absolute path, try the network path -

    Example absolute path:

    Code:
    http://www.mydomain.com/includes/required.php
    Equivalent network path:

    Code:
    /includes/required.php
    Notice the / at the beginning. That tells the server to begin at the root of the domain. So for all intents and purposes it's just like an absolute path.

    I really don't think this is a problem on bloader, though it may be. Rather one on blog/wp-blog-header.php and any files it includes. Best though to make them all network paths. Try it with just one on one of the pages that works already just to see if the server accepts it.

    I'm thinking things worked before because there were only single includes, then you expanded to include pages from included pages. If I'm guessing right, that's when things stopped working.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  7. The Following User Says Thank You to jscheuer1 For This Useful Post:

    urbanvintner (09-25-2010)

  8. #6
    Join Date
    Sep 2010
    Posts
    10
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default tried that already

    this is the result
    Fatal error: require_once() [function.require]: Failed opening required '/blog/wp-blog-header.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/tlcnzcom/public_html/about.php on line 1
    Thanks Again

  9. #7
    Join Date
    Sep 2010
    Posts
    10
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default

    Also if its the include, why is it erroring out only when I apply a query string

  10. #8
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Quote Originally Posted by urbanvintner View Post
    Also if its the include, why is it erroring out only when I apply a query string
    I was thinking that too. Looks like it's fixed now. What was it, something on the server?
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  11. #9
    Join Date
    Sep 2010
    Posts
    10
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default my guess is as good as yours

    I figured out that the variable name in the query string was the problem. I changed that and it worked fine, all I can figure is that the wordpress header, which was the included file uses that query string itself, and that upgrading word press is what broke it in the first place

  12. #10
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Oh! (hits self on forehead), so that was it. Makes sense in a weird sort of way. Hopefully I'll remember that if it ever comes up again.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

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
  •