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));

```
you need to set a value there as well...

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

```

right now "testvar" is empty, so echoing it will echo an empty string... hard to see an empty string that way... 

If you want the string 'testvar' to show in the URL use this:

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

```

You can also pass parameters like this:

```
$("#list").load("selectcity.php",{
   testvar: testvar,
   moreparam1: "some value",
   evenmore: 124
});

```