javascript - AJAX PHP Submission not working -


i'm trying execute php script updates mysql db on click of image. i'm using snippet found online so:

function execute(filename,var1,var2) {     var xmlhttp;     if(window.xmlhttprequest)     {         //code ie7+, firefox, chrome, opera, safari         xmlhttp = new xmlhttprequest();     }     else if(window.activexobject)     {         //code ie6, ie5         xmlhttp = new activexobject("microsoft.xmlhttp");     }     else     {         alert("your browser not support ajax!");     }          var url = filename+"?";         var params = "id="+var1+"&complete="+var2;          xmlhttp.open("post", url, true);      xmlhttp.onreadystatechange=function()     {         if(xmlhttp.readystate==4)         {             //below line fill div id 'response'             //with reply server. can use troubleshoot             //document.getelementbyid('response').innerhtml=xmlhttp.responsetext;              xmlhttp.close;         }     }          //send proper header information along request         xmlhttp.setrequestheader("content-type", "application/x-www-form-urlencoded");         xmlhttp.setrequestheader("content-length", params.length);         xmlhttp.setrequestheader("connection", "close");          xmlhttp.send(params); } 

with link: <a href="javascript:void(0);" onclick="execute(games_do.php,<?=$game['appid']?>,<?=$complete?>)" > </a>

and games_do.php contains:

$appid = $_get['id']; $complete = $_get['complete'];      mysql_query("update ownedgames set complete='".$complete."' steamid='".$steamid."' , appid='".$appid."'") or die(mysql_error()); 

however, nothing seems happen on click. suggestions appreciated! :)

the parameter values execute function in <a> tag should enclosed within quotes function expects string value.

in addition, point mentioned in d. schalla's answer should considered.


Comments

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -