Home » Wordpress » AJAX loading of outside HTML content works perfect on localhost but not on server

AJAX loading of outside HTML content works perfect on localhost but not on server

Posted by: admin November 30, 2017 Leave a comment


I am trying to render content generated by a php file in [jQuery Colorbox][1] through AJAX in my WordPress site. The PHP resides on the same server in the same domain. It works perfect when I run it on localhost but it’s not working on the server.

Here is the link to my site – http://shabdcreatives.com/portfolio

The links themselves are not invalid, for example the following link works fine on its own:


I just won’t open inside the colorbox.

Also the php file I am trying to load is just a fragment and DOES NOT CONTAIN any <html> or <body> tags.

I tried the colorbox support group but no replies from them yet

This is the code in the CatGridPost.php file that i am calling in the colorbox..
i tried calling a plain text file too… it returned no error.. but the colorbox did not show its contents either

$thepost = get_post($_GET["ID"]);
$thecontent = $thepost->post_content;
$thetitle = $thepost->post_title;
$thelink = get_permalink($_GET["ID"]);
<div id="cg-post-container">
<div id="cg-post-title">
    <a href="<?php echo $thelink; ?>"><?php echo $thetitle; ?></a>
<div id="cg-post-content">  
        <?php echo $thecontent; ?>


Hi it can be a server issue with mod_security , i had a similar issue with one of my clients server i disabled the mod_security and it solved the issue.

But i was not getting an 404 error.

here is the link for reference http://drupal.org/node/370651

Also try changing the file permission : /wp-content/plugins/catgrid/includes/CatGridPost.php

If it is a WordPress whydont you try the inbuilt Ajax function of wordpress



For some reason your server is responding with a 404 not found, then returning the document.

With the AJAX request it fails because obviously the client thinks that the request went badly.

When you load the page the browser just displays what you send to it because it thinks the content you’re displaying is just a 404 page. (A Custom 404 page)

I can’t help you fix this problem since I can’t tell what is happening on the server side.

Perhaps Ctrl+F for 404 in the folder?

You can confirm this as being the problem by clicking a few images then going to Inspect Element in Google Chrome, then enabling the console. From there you can see that it says the GET failed with 404

Image showing the server is returning a 404