I'm building a webpage in php, and want to change a $_SESSION variable from true to false on the click of a button.
I understand that php runs serverside, and as such I need to use AJAX to change that variable.
What I'd really like is a code to call an AJAX function (called methods in AJAX?) from a form button, the AJAX script then changes the SESSION variable. I'd really like to avoid page reload.
So, the form should look something like this:
<form action=ajaxMethod() method="get">
<input type="submit" value="X" id="close">
</form>
And this is the php version of what I want the AJAX script to do:
function ajaxMethod() {
$_SESSION["variable"] = false;
}
However, I'm such a noob when it comes to JS, and especially AJAX, that I am unsure how to create that AJAX method.
As simple as possible... If simple is possible...
Any help?
Also: The page I'm building is propeitary and belongs to the company I'm working for, and as such I'm not at liberty to divulge the actual code, but the examples above feels like they describe what I'd like to accomplish. If needed, I'll explain further.
I'd love to avoid using JQuery, if at all possible.