index.html
<html>
<head><title></title></head>
<body>
<button onclick="display_data()">view</button>
<div id="show"></div>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/
libs/jquery/1.3.0/jquery.min.js">
</script>
<script type="text/javascript" id="display"></script>
<script>
function display_data(){
var s = 1;
var dataString = 'show=' + s;
$.ajax({
type: "POST",
url: "blog.php",
data: dataString,
success: function(data){
document.getElementById("display").innerHTML = data;
replace();
}
});
}
</script>
</body>
</html>
blog.php
<?php
if (isset($_POST['show'])) {
$date = date("d/M/Y");
echo '
function replace() {
var d = "'.$date.'";
document.getElementById("show").innerHTML = d;
}
';
}
?>