I am trying out a bit of Ajax ( via jQuery ) in WordPresss. I have everything working correctly but for some reason I have to have the full URL to the PHP handler file even though it’s located in the same directory as the script.
Here’s the code:
$.post('http://full/url/to/file.php', $("#form").serialize(), function(data){
do stuff
...
});
Why cant I just put “file.php” into that? Why does it need the full URL? Or more importantly, what can I put in there that would work on any site without the end user having to put in the full URL every time?
P.S. I have read the problem with Ajax and the path to the PHP page but I just got a bit more mixed up. I have also read the Ajax in plugins page on the WordPress codex but I couldn’t see a relevant example in there. I suspect this might have something to do with wp_localise_script()
but I’m not sure.