开发者

Busy spinner while retrieving data

I would like to add a busy spinner while retrieving data from a Mysql database. The code is written in PHP. The problem is that it takes too long time to get back the result from Mysql database and I would like that the user get some indication that something is happening.

Is there a way to do that?

The code looks like this:

<?php
include "db.php"
?>

<html>
<head>
<title>Test</title>

</head>

<body>

<?php
    // This part takes too long time to execu开发者_JAVA技巧te

    $query = "SELECT * FROM bokings WHERE Bokningsnr = '83270'";
    $result = mysql_query($query);

    while ($row = mysql_fetch_array($result)){
        $showid = $row['showid'];
        echo $showid."<br>";
    }

?>

</body> 
</html>

Regards.

/Oualid


There are a lot of ways to do that. It also depends on how you're calling the data.

the simple approach if youre using JQuery is to have an image with the spinning art. hide it initially and show it on an ajax call.

<img id="myspinner" src="yoursinnping.png" alt="processing please wait" style="display:none;"/>

<input type="button" value="click me" onclick="myajaxfunction();" />

then in an ajax call

function myajaxfunction () {
       $('#smyspinner).show();
        // do ajax call here
        //  on success  $('#smyspinner).hide();


One way is to simply take a .gif image with the spinning animation and place it on the screen (you will need to find an apropriate place for it) when you send a query to the db. the image can be found here

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜