JQuery not working on remote machines
Hello,
I am new to jQuery. I have written my application in a VMWare applicance running linux and php. Code is pretty simple.
- <html>
<head>
<script src="jquery-1.4.1.js" />
<script>
function setup_country_change() {
$('#countries').change(update_cities);
}
function update_cities() {
var countryVar=$('#countries').attr('value');
$.get('get_cities.php?country=' + countryVar, show_cities)
}
function show_cities(res) {
$('#cities').html(res);
}
$(document).ready(setup_country_change);
</script>
</head>
<body>
<form>
<table width="100%">
<tr>
<th>Countries</th>
<td style="align:left">
<select id="countries">
<option value="" selected>Please choose Country</option>
<option value="uk">UK</option>
<option value="ie">Ireland</option>
</select>
</td>
</tr>
<tr>
<th>Cities</th>
<td style="align:left">
<select id="cities">
<option value="">Please choose city</option>
</select>
</td>
</tr>
<table>
<form>
</body>
</html>
get_cities.php
----------------------
- <?php
switch($_REQUEST['country'])
{
case 'ie':
$cities = array('Cork', 'Dublin', 'Galway', 'Limerick');
break;
case 'uk':
$cities = array('Bath', 'Birmingham', 'Bradford');
break;
default:
$cities = false;
}
if (!$cities) echo 'please select country first';
else foreach($cities as $city) {echo "<option>$city</option>";}
?>
Apparently this sample works only in chrome (test inside the VM and outside).
However when I test in firefox (inside the VM and outside) it does nothing when a country is selected.
Also from outside when I test in IE, it does nothing.
Can you please see what I am doing wrong.