Solution:
this my.js in the js folder of the theme
jQuery(document).ready(function refresh_div() {
jQuery.ajax({
url:'//MySite/mysite/wp-admin/admin-ajax.php',
action:'MyAjaxFunction',
type:'POST',
dataType:json,
success:function(results) {
jQuery(".result").html(results.result);
}
});
}
t = setInterval(refresh_div,1000););
the functions.php file of the theme adding this in the end:
function MyAjaxFunction(){
//get the data from ajax() call
$jsonresult = array();
$TableContent = $wpdb->get_results("
SELECT MAX(`post_date`) AS MaxDate FROM wp_posts"
);
foreach($TableContent as $Content){
$jsonresult['result'] = $Content->MaxDate
}
echo json_encode($jsonresult);
die();
}
// creating Ajax call for WordPress
add_action( 'wp_ajax_nopriv_MyAjaxFunction', 'MyAjaxFunction' );
add_action( 'wp_ajax_MyAjaxFunction', 'MyAjaxFunction' );