If not, what would be a workaround?
Something like this:
Page 1:
<script>
var test = '';
*** AJAX Request to Page 2 ***
document.write(test);
</script>
Page 2:
<script>test = "test Data";</script>
If not, what would be a workaround?
Something like this:
Page 1:
<script>
var test = '';
*** AJAX Request to Page 2 ***
document.write(test);
</script>
Page 2:
<script>test = "test Data";</script>
Why not set the variable value in the callback of the ajax request? Something like this:
$.ajax({
url: "test.html",
context: document.body
}).done(function(res) {
test = res.value;
});
The script from page 2 can return an JSON Object like {value: 'test Data'}
You can set variables with the page you request, if this page runs some javaScript. I assume your ajax request is calling page 2?
However, it would make more sense, I think, to set the variable in the callback of your ajax request.
Since you did not list any server side languages, I'm also assuming you are talking about changing client-side variables.