Reputation: 2647
I have an ajax.php file in my Wordpress themes folder, and this was working fine on the DEV server. However, when I moved it to another server, the script that I have written no longer works... bizarre!
Im now rolling back to try and find the problem, but its most annoying because the very same version works on another server?!
Here's the code (for what its worth...)
Javascript Call:
function change_event(ID){
//alert("ID: "+ID);
$.post('wp-content/themes/muni/ajaxcalls.php',
{ id: ID },
function(data){
alert('complete: '+data);
//$('#showingevent').html(data);
});
}
ajaxcalls.php
require_once("../../../wp-blog-header.php");
global $more;
At this point, it breaks. There is no point including the code I have written after the require. If I comment this line, the code below works.
If I browse directly to the ajaxcalls.php file, I get the results I am expecting, but it will not feed back to the success function of the ajax call.
Any help would be greatly appreciated
Cheers SO!
Tom
edit: I'm firing change_event using this:
$('.eventoption A').click(function(ev){
ev.preventDefault();
change_event($(this).attr('id'));
clearInterval(timer);
});
I've also updated the change_event() function to reflect the one that I'm using rather than the debug that I was using before.
The problem happens as soon as I include the wp-blog-header.php file.
Upvotes: 0
Views: 1713
Reputation: 1001
use this. It is working on localhost, and i hope it will also work for live server.
$folder = substr(substr($_SERVER["REQUEST_URI"],1), 0,
strpos(substr($_SERVER["REQUEST_URI"],1), "/"));
$ajax_url = realpath($_SERVER["DOCUMENT_ROOT"]).'/'.$folder.'/wp-blog-header.php';
Upvotes: 0