Problem with variable as parameter in get()
My code looks like this:
- <script type="text/javascript">
$(document).ready(function(){
$.get("/rou/ajax/liceu.php", { country: "1", city: "1" },
function(data) {
$('div#text').html(data);
});
$(function() {
// navigate to page on click event
$('#nav_combo').bind('change', function() { goToPage(); } );
});
function goToPage() {
$.get("/rou/ajax/date.php", { city: $('nav_combo').val(),
country: "<? echo $country; ?>" },
function(data) {
$('div#text').html(data);
});
}
});
</script>
<form>
<select id="nav_combo">
<option value="1">One</option>
<option value="2">Two</option>
<option value="3">Three</option>
<option value="4">Four</option>
<option value="5">Five</option>
</select>
</form>
<div id="text"></div>
The problem is that after you change the value from the default one to: "Two", "Three", ..., the script doesn't send GET requests using the both,
country and
city parameters, but only with
country.
How can I use
$('nav_combo').val(), which is a variable, as a parameter in the request?
Thank you.