Skip to content
Advertisement

SELECT doesn’t retrieve updated data from DB after INSERT

On one page I’m sending AJAX-request to itself. After getting this request in success-function with PHP I’m adding new record to table “some_table” in some MySQL database. And after that in the same success-function I’m selecting data from this table and showing it on the page by JQuery. The problem is that all old records are shown but not the record which I’ve added just:

JavaScript

Could anybody hint how to solve it?

Advertisement

Answer

You can’t expect for a page to execute the code again if the page has already loaded.

Take this as an example:

Client-side:

JavaScript

Server-side:

JavaScript

Try something like this(if someone finds an error, please correct it, thanks).

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement