php - jQuery button response time issue while auto refreshing a DIV in every X second -
I am using this code to refresh my main DIV in my main page (reading php name) :
jQuery (document) .ready (function interval () {setInterval (jQuery ('# myMainDiv'). Load ('readings_content.php'), 10000);}); In readings_content.php, the sensor readings are being checked from the database and according to sensor counting, draw a screen like a security cam screen. This code is like this:
$ db_sensors-> Query ("Select from tbl_sensors * where position = 1"); If ($ db_sensors-> record count> 0) {while ($ db_sensors-> nextrow ()) {$ sensors = $ db_sensors-> Field; $ Sensor = $ sensor ["name"]; $ Sensory value = $ sensor ["final outline"]; Echo "& lt; div & gt;"; Echo "sensor name:". $ Sensorname "& Lt; br & gt;"; Echo "Final Reading:" $ Sensor value; Echo "& lt; / div & gt;"; }} This idea is working well. But due to this loop (refreshing 9-16 censors) refresh time is taking. This is generally okay because the page is not reloading, just changing the value when reading a new sensor reading but there is a button in my main page (reading.fp). The response time for this button takes about 10 seconds, even though I am using local databases.
I want to speed up this fresh process or if it is possible, then I want to stop this latest thing (or the page is happening anytime) when I click on the button and its Working onClick event
After my whole research, I started trying all different options. And it was just fine when I changed the code of jQuery like this:
setTimeout ('sensorcells_load ()', 10000); Function sensor sales_load () {jQuery ('# sensor sensor'). Load ('dashboard_saint.fp'); SetTimeout ('sensorcells_load ()', 10000); } I'm not a jQuery guy and I really do not know why this works but nobody else does it. But it solved my problem.
Comments
Post a Comment