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.
The following will send the two variables in a single request
but window.location.href is not an AJAX request. Calling the above code will cause the browser location to change to myphpfile.php.
See this page for how to get started with AJAX, or alternatively you could consider using jQuery.