req.open("GET", "http://mysite.com/regional/continent.php?data="+src+"&val="+val+"&affiliate_num="+affiliate_num); The "data" var and the "val" var above can be retrieved on the targeted continent.php page with these get statements and echoed with the php $data=$_GET['data']; echo 'continent data = ',$data;?><BR><? $val=$_GET['val']; echo 'continent val = ', $val;?><BR><? BUT I can't get the "affiliate_num" var to carry through to the next page. What I mean is that the same GET functions won't pull the value $affiliate_num=$_GET['affiliate_num']; echo 'continent affiliate num = ', $affiliate_num; Gets this result -- continent affiliate num = undefined The "req.open" line of code at the beginning is part of this script. I simply need to carry more vars over to that next page and can't --- <script language=Javascript> function Inint_AJAX() { try { return new ActiveXObject("Msxml2.XMLHTTP"); } catch(e) {} //IE try { return new ActiveXObject("Microsoft.XMLHTTP"); } catch(e) {} //IE try { return new XMLHttpRequest(); } catch(e) {} //Native Javascript alert("XMLHttpRequest not supported"); return null; }; function dochange(src, val, affiliate_num) { var req = Inint_AJAX(); req.onreadystatechange = function () { if (req.readyState==4) { if (req.status==200) { document.getElementById(src).innerHTML=req.responseText; //retuen value } } }; req.open("GET", "http://Bungeebones.com/regional/continent.php?data="+src+"&val="+val+"&affiliate_num="+affiliate_num); //make connection req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=iso-8859-1"); // set Header req.send(null); //send value } window.onLoad=dochange('continents', -1,-1); // value in first dropdown </script> Then, after I get that var to work I will need to add it to this line -- echo "<select name='countries' onChange=\"dochange('states', this.value")\">\n"; Would just a comma and the var name work? Like this -- echo "<select name='countries' onChange=\"dochange('states', this.value, affiliate_num")\">\n"; or like this echo "<select name='countries' onChange=\"dochange('states', this.value, ".$affiliate_num.")\">\n";
Hi, Can you elaborate? It is an ajax app that I wrote and will be "cross-domain" too, but I can't get it to work on my own domain even Why doesn't the ""&affiliate_num="+affiliate_num); " part of the first line's (of this post) code not work but the part dealing with the data and val variables does? Or perhaps someone can tell me how to "echo" the url that the req.open function is attempting? Thanks
cross-domain ajax needs special consideration, client side & server side. Also you should encodeURIComponent variables that you pass.