Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
30
rated 0 times [  34] [ 4]  / answers: 1 / hits: 75715  / 11 Years ago, sun, april 14, 2013, 12:00:00

Am trying to refresh data stored in a div every 10 seconds using jQuery.



My HTML code is:



<!DOCTYPE html>
<head>
<title>Untitled Document</title>

<script src=http://code.jquery.com/jquery-latest.js></script>

<script>
$(document).ready(function(){
setInterval(function() {
$(#latestData).load(getLatestData.php #latestData);
}, 10000);
});

</script>
</head>

<body>
<div id = latestData>

</div>
</body>
</html>


And the PHP code I am using (temporarily as I know this won't change due to the same data):



<?php

echo test;

?>


However, it isn't even showing test on the html page.. could anyone suggest where I have gone wrong?



Many thanks


More From » php

 Answers
7

jQuery load method works in a different way. Try reading its documentation.



You don't have to specify destination element ID twice, remove the second one, like this:



$(#latestData).load(getLatestData.php);

[#78918] Friday, April 12, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
kalia

Total Points: 92
Total Questions: 82
Total Answers: 120

Location: Laos
Member since Fri, Sep 11, 2020
4 Years ago
;