To elaborate a bit on this, our main.php (site/templates/) contains the markup with an inline ajax call. The point of this is that if javascript is available on the client, we can send additional markup to the page. In this example, we are just popping an alert box.
site/templates/main.php:
<html>
...
<body>
...
<?php
if ($page->get("title") == "Home")
{
echo "<script type='text/javascript'>
var stuff = 1;
$.ajax({
type: 'POST',
url: '" . $config->urls->templates . "somefile.php',
data: {'inspection': stuff},
dataType: 'json',
success: function(returnedData, status, request)
{
alert('Yay! ' + returnedData);
},
error: function()
{
alert('crap...');
}
});
</script>";
}
?>
</body>
</head>
Where url is '/site/templates/somefile.php'
site/templates/somefile.php:
<?php
if($config->ajax)
{
json_encode("Hello");
exit;
}
?>
However, this fails with 403 (Forbidden).
Placing the contents of somefile.php at the top of main.php and replacing the ajax url with '$page->url' works just fine.
Is there any reason why we would be unable to post to another php script?
Thanks!