外部HTML内容的AJAX加载在localhost上完美,但在服务器上不起作用
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:
http://shabdcreatives.com/wp-content/plugins/catgrid/includes/CatGridPost.php?ID=33
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
require_once("../../../../wp-blog-header.php");
$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>
<div id="cg-post-content">
<?php echo $thecontent; ?>
</div>
我试图通过我的WordPress中的AJAX渲染由[jQuery Colorbox] [1]中的php文件生成的内容 现场。 PHP驻留在同一域中的同一服务器上。 当我在localhost上运行它时它工作得很完美,但它不能在服务器上运行。 p>
这是我网站的链接 - http://shabdcreatives.com/portfolio p>
链接本身并非无效,例如以下链接可以自行运行:
http:/ /shabdcreatives.com/wp-content/plugins/catgrid/includes/CatGridPost.php?ID=33 p>
我不会在彩盒内打开。 p >
我试图加载的php文件只是一个片段,并且不包含任何 我尝试了colorbox支持组,但没有回复它们 p>
这是我在调用的CatGridPost.php文件中的代码 colorbox ..
i尝试调用一个纯文本文件...它没有返回任何错误..但颜色框没有显示它的con 帐篷 p>
p>
div>&lt; html&gt; code>或
&lt; body&gt; code>标签 。 p>
require_once(“../../../../ wp-blog-header.php”);
$ thepost = get_post($ _ GET [“ID”]);
$ thecontent = $ thepost-&gt; post_content;
$ thetitle = $ thepost-&gt; post_title;
$ thelink = get_permalink($ _ GET [“ID”]);
? &gt;
&lt; div id =“cg-post-container”&gt;
&lt; div id =“cg-post-title”&gt;
&lt; a href =“&lt;?php echo $ thelink; ?&gt;“&gt;&lt;?php echo $ thetitle;?&gt;&lt; / a&gt;
&lt; / div&gt;
&lt; div id =”cg-post-content“&gt;
&lt;?php echo $ thecontent;?&gt;
&lt; / div&gt;
code> pre>
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