weixin_33676492 2017-12-14 14:05 采纳率: 0%
浏览 14

divs的PHP AJAX问题

having a few issues at the moment regarding updating the content of a div using ajax and php. I am trying to echo the price in the php script into to the div and it is not happening....maybe I'm missing something. This is a modified and simplified example of my problem.

HTML CODE:

<!DOCTYPE html>
<html>

<meta name="viewport" content="width=device-width, initial-scale=1.0">

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>

<script>
function autoRefresh_div(){
    $("#tester").load("getPriceTest.php");
}
setInterval('autoRefresh_div()', 1000);
</script>

<body>

<div id="tester">3.33</div>

</body>
</html>

PHP CODE:

<?php

echo "2.22";

?>
  • 写回答

1条回答 默认 最新

  • weixin_33749131 2017-12-14 14:08
    关注

    Put the function in without the ', or change it to:

    <!DOCTYPE html>
    <html>
    
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
    
    <script>
    function autoRefresh_div(){
        $("#tester").load("getPriceTest.php");
    }
    setInterval(function(){
        autoRefresh_div()
    }, 1000);
    </script>
    
    <body>
    
    <div id="tester">3.33</div>
    
    </body>
    </html>
    
    评论

报告相同问题?