I am pretty new to JavaScript and PHP.
I'd like to create a JavaScript function that contains a variable, passes this on to PHP on another page and opens that page.
Here is what I got so far (not working):
My JS:
function test()
{
$.ajax(
{
url: "my-new-page.php",
type: "POST",
data:
{
varJS: "XXX"
},
error:function(err)
{
alert(err.statusText);
},
success: function(data)
{
window.open("my-new-page.php");
}
});
}
My PHP (on the new page):
$varPHP = $_POST['varJS'];