OK, not really sure if this is possible but thought I’d ask anyway 🙂
I have a HTML page which contains some information and a link.
The link calls a JavaScript confirm dialog box.
If the user selects OK then I want to call a function in a PHP file, but in the background, i.e I don’t want to change page, reload or anything.
Is this possible?
Thanks
T
Use AJAX. The following uses jQuery:
For more information, check out jQuery’s documentation for AJAX. If you cannot use jQuery, there are many tutorials on using native JavaScript to make AJAX Requests.
If you are returning a large amount of data back to your success function from PHP, it would be worthwhile for you to return the data from PHP as a JSON encoded array, which can be safely parsed client-side into a JavaScript object.