0

I have index.html like this

<!DOCTYPE html>
<html lang="en">
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/
libs/jquery/1.3.0/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
var auto_refresh = setInterval(
function ()
{
//alert("abc");
$('#mydiv').load('xyz.php').fadeIn("slow");
}, 1000); 
});
</script>
</head>
<body>
<div id="mydiv"> </div>
</body>
</html>

In same folder there is xyz.php file whose code is this:

<?php
echo "My first PHP script!";
?>

When I uncomment //alert("abc"); and comment $('#mydiv').load('xyz.php').fadeIn("slow"); alert message comes every second but vice versa is not working when I am calling php file and commenting alert message. Why?

4

2 回答 2

0

It´s working for me, but you only can see the content one time, because .load function is replacing the old content, change

$('#mydiv').load('xyz.php').fadeIn("slow");  

with this

$('#mydiv').append($('<div >').load('xyz.php'));
于 2013-10-17T15:29:14.383 回答
0

我将 index.html 重命名为 index.php 并通过localhost/firstproject/index.php. 那行得通

于 2013-10-18T10:18:21.237 回答