Intitialize a session variable after onclick event is fired
-
i want to initialize a php session variable when user clicks on a link, using a php function or any other way. for example
-
i want to initialize a php session variable when user clicks on a link, using a php function or any other way. for example
u can use ajax. u must create a function in your javascript code that send ajax request to your php file and get response from that.
function getXMLHttpRequest()
{
if (window.XMLHttpRequest) {
return new window.XMLHttpRequest;
}
else {
try {
return new ActiveXObject("MSXML2.XMLHTTP.3.0");
}
catch(ex) {
return null;
}
}
}function do_somting(){
xhr= getXMLHttpRequest();
xhr.onreadystatechange=function()
{if(xhr.readyState==4 && xhr.status==200) { //get response here from php file with xhr.responseText; } } xhr.open("GET","file.php",true); xhr.send(null);
}
and in php file that contains php functions.
-
u can use ajax. u must create a function in your javascript code that send ajax request to your php file and get response from that.
function getXMLHttpRequest()
{
if (window.XMLHttpRequest) {
return new window.XMLHttpRequest;
}
else {
try {
return new ActiveXObject("MSXML2.XMLHTTP.3.0");
}
catch(ex) {
return null;
}
}
}function do_somting(){
xhr= getXMLHttpRequest();
xhr.onreadystatechange=function()
{if(xhr.readyState==4 && xhr.status==200) { //get response here from php file with xhr.responseText; } } xhr.open("GET","file.php",true); xhr.send(null);
}
and in php file that contains php functions.
thanks for help