function loadContent(id)
{
// Here I build an object that is sent with the Ajax call.
// It contains the Php method to call, and the Id of the
// wordpress page to be loaded.
var data = {
action: "tnet_load_post_content",
pageId: id
};
// Builds the Ajax call, executes it, and calls onContentLoaded on success.
useAjax(data, onContentLoaded);
}
function useAjax(data, onSuccess)
{
$.ajax({
type: "post",
cache: false,
// The target for the wordpress Ajax call, was enabled via wp_localize_script() in the Php code.
url: ajaxAdmin.ajaxurl,
// The parameters that get send along
data: data,
// Method that is called on success
success: onSuccess
});
}
function onContentLoaded(response)
{
// The loaded content is put into the designated container.
contentContainer.html(response);
}