Home > Article > Web Front-end > jQuery PHP implements dynamic digital display effects_jquery
HTML
This example assumes that the number of current online users is to be dynamically displayed on the page (without refreshing the entire page, only partially refreshing dynamic numbers), which is commonly used on some statistical platforms. Just define the following structure in the HTML page:
jQuery
First we need to define an animation process, using jQuery’s animate() function to realize the transformation process from one number to another. The following magic_number() custom function integrates the code as follows:
Then the update() function uses jQuery's $.getJSON() to send an ajax request to the background number.php. After getting the PHP response, it calls magic_number() to display the latest number. In order to see better results, we use setInterval() to set the interval between code execution.
PHP
In the actual project, we will use PHP to obtain the latest data in the database, and then return it to the front end through PHP. In this example, for a better demonstration, random numbers are used, and finally returned to the front-end js in json format. The number.php code is as follows:
The above is the jQuery PHP code that this article shares with you to implement dynamic digital display effects. I hope you will like it.