Im trying to pass two JavaScript variables to PHP variables.
function myFunction(){
var one = 'one';
var two = 'two';
}
After doing my research, I have pretty much come to the conclusion I am going to have to use AJAX, something like
window.location.href = "myphpfile.php?one=" + one;
window.location.href = "myphpfile.php?two=" + two;
But Im having trouble picking up the variable in PHP using
$_GET['one']
$_GET['two']
Im also confused as to whether I am calling the php script twice. Is there a working way to pass two variables? I have found several ways to pass one but none to pass two.
window.location.hrefis a browser redirection, not an AJAX call. Since you have tagged jquery-ajax, start reading here.$.get('myphpfile.php?one=one&two=two'...), but there's more to it than that...isset($_GET['one'])and tell us what happens.