javascript - Combine AJAX request to load new page with variables -
i have 3 stored js variables (wordchoiceone, wordchoicetwo, wordchoicethree). have these stored, want run function called saveusername(). function should following:
take jquery variables above , pass them php and load file register-form.php div register-login-form
so have following ajax request, handles reloading of form. i've never combined jquery php before how can add part in pass 3 variables?
function saveusername(wordchoiceone, wordchoicetwo, wordchoicethree){ { var xmlhttp; if (window.xmlhttprequest) {// code ie7+, firefox, chrome, opera, safari xmlhttp=new xmlhttprequest(); } else {// code ie6, ie5 xmlhttp=new activexobject("microsoft.xmlhttp"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readystate==4 && xmlhttp.status==200) { document.getelementbyid("login-register-form").innerhtml=xmlhttp.responsetext; } } xmlhttp.open("get","register-form.php",true); xmlhttp.send(); } what add pass 3 variables , convert them php vars $ sign?
function saveusername(wordchoiceone, wordchoicetwo, wordchoicethree){ { var xmlhttp; if (window.xmlhttprequest) {// code ie7+, firefox, chrome, opera, safari xmlhttp=new xmlhttprequest(); } else {// code ie6, ie5 xmlhttp=new activexobject("microsoft.xmlhttp"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readystate==4 && xmlhttp.status==200) { document.getelementbyid("login-register-form").innerhtml=xmlhttp.responsetext; } } xmlhttp.open("get","register-form.php?one="+wordchoiceone+"&two="+wordchoicetwo+"&three="+wordchoicethree,true); xmlhttp.send(); } then php side, use $_get['one'], $_get['two'] , $_get['three']
Comments
Post a Comment