Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to realize Commodity Notification by php

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly introduces "how to achieve commodity notification in php". In daily operation, I believe that many people have doubts about how to achieve commodity notification in php. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful to answer the doubts about "how to achieve commodity notification in php". Next, please follow the editor to study!

Php to achieve commodity notification method: 1, create js code and set Ajax request interface every 10 seconds; 2, query the database whether there is a new order; 3, through "public function sendOrderNotice () {...}" to achieve order reminder.

This article operating environment: Windows7 system, PHP7.1 version, Dell G3 computer.

How does php realize commodity notification?

PHP uses AJax polling to realize real-time reminder of new orders

Business logic: Ajax requests the interface every 10 seconds. The interface will query whether there are new orders in the database. If so, the number of new orders will be returned. The background receives a voice prompt to change the number of background reminders.

The reminder box can be linked to the order list, and the reminder will disappear after the order status is changed in the background.

This logic can also be used to implement the background notification function, and it can also be implemented with scheduled tasks.

1. JS code

Var remind = 1; var mp3 = $("# mp3") [0]; var play= 0; if (sessionStorage.num) {$(".remind") .text (sessionStorage.num);} $.ajax ({url: "/ sendOrderNotice", success:function (data) {sessionStorage.num = data) $(".remind") .text (data); remind = data;play=data; remind

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report