takn25 Posted April 29, 2011 Share Posted April 29, 2011 Hi, I am not the best with Javascript or Ajax I just want to perform a tiny thing. I want to know how can I pass a GET variable in an anchor tag to PHP Ill explain further below. <script type='text/javascript'> function load() { if (window.XMLHttpRequest) { xmlhttp = new XMLHttpRequest(); }else { xmlhttp = new ActiveXObject('Microsoft.XMLHTTP'); } xmlhttp.onreadystatechange = function() { if (xmlhttp.readyState == 4 && xmlhttp.status == 200) { document.getElementById('adiv').innerHTML = xmlhttp.responseText; } } xmlhttp.open('GET', 'include.inc.php', true); xmlhttp.send(); } </script> </head> <body> <?php echo "<a href='#' onclick='load();'>click </a>" ?> <div id='adiv'> </div> Ok focus on this part which is <a href='#' onclick='load();'>click </a>. Instead of # there would be some primary number generated through mysql. For instance ?cid=25, ?cid=26 and so on you get the picture. I want to know how can I pass these to my include.inc.php. Lastly I would like to know what should my url be for these to pass because I used to extact data from mysql and echo URLS as <a href=' include.inc.php?$cid' > </a> If I do this now wont this just directly take me to the page So what is the proper way of passing stuff. Thanks any help is appreciated hope I made some sense was kinda hard explaining! Quote Link to comment https://forums.phpfreaks.com/topic/235097-a-little-help-with-anchor-tags/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.