I use a combination of PHP and JS.
I have a URL parameter in my parent URL called market.
http://example.com?market=stackoverflow
I store it to a variable.
<?php
$market = $_GET['market'];
?
Then in JS:
<script>
var market;
market = <?php echo $market; ?>;
</script>
Then I have a function - xmlHTTPREQUEST. This is where the problem lies. I need to pass variable market into the function - append it to the script being called - mexx.php
<script>
function test() {
var ajax = new XMLHttpRequest();
ajax.onreadystatechange = function() {
if (ajax.readyState == 4) {
xxx = (ajax.responseText);
console.log(xxx);
}
};
ajax.open("GET", "'mexx.php?market='+market", true);
ajax.send(null);
}
</script>
I can't see anything in console - all blank.
Where is the syntax error?
ajax.open("GET", "mexx.php?market="+ encodeURIComponent(market), true);, but why do you need to send something that the server already has