Question: I have a javascript function that loads a PHP page and passes a variable(testvar) to it

```
function selectcity()
{

      var testvar = "test text";
     $("#list").load("selectcity.php?testvar");
     $.ajaxSetup({ cache: false });

}

```

Now in the selectcity.php page,I am trying to retrieve the variable like this :
But not working,Can someone pls help.

```
<?php
echo $_GET['testvar'];
?>

```

Answer: 
You didn't set the value, only the variable name in the URL.

Change to:

```
$("#list").load("selectcity.php?testvar=" + encodeURIComponent(testvar));

```
Just try with:

```
$("#list").load("selectcity.php", {
    testvar: testvar
});

```