Hack Forums
PHP/JS/AJAX HELP not refreshing. - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Webmasters (https://hackforums.net/forumdisplay.php?fid=141)
+---- Forum: Website Construction (https://hackforums.net/forumdisplay.php?fid=50)
+---- Thread: PHP/JS/AJAX HELP not refreshing. (/showthread.php?tid=5292275)



PHP/JS/AJAX HELP not refreshing. - TrojaηHorsє - Jun 3, 2016

I am trying to refresh SQL data that is displayed onto my page. I want it to refresh every second. At the moment, after the balance has been displayed, after the 1 second the data stays but it doesn't update.

I have had to upload the code onto a different site as it won't let me put it here without blocking me and giving a cloudflare error.
CODE:
http://kopy.io/tJvzq#bLEXdZmmwjWOki


I think my problem is that the $_SESSION['Money'] is not being refreshed however, I don't know how to change this as I am only familiar with PHP.

Can someone please be kind enough to help me out with this

Thanks.


* - Shroomies_temp - Jun 4, 2016

(Jun 3, 2016 03:52 PM)TrojaηHorsє Wrote:  I am trying to refresh SQL data that is displayed onto my page. I want it to refresh every second. At the moment, after the balance has been displayed, after the 1 second the data stays but it doesn't update.

I have had to upload the code onto a different site as it won't let me put it here without blocking me and giving a cloudflare error.
CODE:
http://kopy.io/tJvzq#bLEXdZmmwjWOki


I think my problem is that the $_SESSION['Money'] is not being refreshed however, I don't know how to change this as I am only familiar with PHP.

Can someone please be kind enough to help me out with this

Thanks.

You need to use something called AJAX.
http://www.w3schools.com/ajax/ajax_xmlhttprequest_send.asp

You would need to send a request to the server with each JS call and then update the results on page.
It would look like this:
http://kopy.io/6EBmj
I added the getAjax GET variable, just so you dont get "whole" page each time, but rather get just the money number with ajax call.


* - TrojaηHorsє - Jun 4, 2016

(Jun 4, 2016 01:04 AM)Shroomies_temp Wrote:  You need to use something called AJAX.
http://www.w3schools.com/ajax/ajax_xmlhttprequest_send.asp

You would need to send a request to the server with each JS call and then update the results on page.
It would look like this:
http://kopy.io/6EBmj
I added the getAjax GET variable, just so you dont get "whole" page each time, but rather get just the money number with ajax call.

Hey,

thanks for the answer mate, it works now but I've somehow managed to make it work without needing ajax which is weird because even i was sure i needed to use ajax haha.

TH.