There are many ways to achieve that. The one option would be to call a processor function via Ajax. This function returns you all desired details of your page. The content can be sent and received in the json format, for instance.
First off, the ajax call in your template file:
Your controller, a few lines in the functions.php:
Your processor (could be a function in your functions.php file):
First off, the ajax call in your template file:
Code:
var slug = 'your_slug';
$.ajax({
url: 'http://your-domain.com',
type: 'GET',
data: {
'getPageContent': slug
},
dataType: 'json',
success: function (data) {
if(data) {
console.log(data.content);
}
}
});
Your controller, a few lines in the functions.php:
PHP Code:
if(!empty($_GET['getPageContent'])) {
echo json_encode(your_function($_GET['getPageContent']));
exit();
}
Your processor (could be a function in your functions.php file):
PHP Code:
function your_function($slug) {
$data = null;
$id = null;
$id = lowercase(str_replace('/', '', str_replace('..', '', $slug)));
if($id) {
$data = getXml(GSDATAPAGESPATH.$id.'.xml');
}
return isset($data->content) ? array('content' => (string)$data->content) : null;
}