Hello everybody, i'm really stuck and i think this is the only place to get an answer.
My situation: i use the getJSON request to fill a select (with cities names) after the user have choosen his region.
I paste some code:
- <html>
<head>
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" charset="utf-8">
$(function(){
$("select#reg").change(function(){
alert ('start');
alert($(this).val());
$.getJSON("script/getProvinceRegione",{id: $(this).val(), ajax: 'true'}, function(j){
alert('callback time!');
var options = '';
for (var i = 0; i < j.length; i++) {
options += '<option value=\"' + j[i].optionValue + '\">' + j[i].optionDisplay + '<\/option>';
}
$("select#prov").html(options);
})
})
})
</script>
</head>
<body>
<form>
Region: <select id="reg" tal:define="regioni python:context.script.getRegioni()">
<tal:block repeat="tuplaReg regioni">
<option tal:attributes="value python: tuplaReg[0]" tal:content="python: tuplaReg[1]"/>
</tal:block>
</select>
City: <select id="prov">
</select>
</form>
</body>
</html>
The problem is that callback is never called. I used firebug and i have seen that when i change region the getJSON function is called and my script (python) return this JSON:
[{'optionValue': '03', 'optionDisplay': 'roma'}, {'optionValue': '04', 'optionDisplay': 'milano'}] Why my callback is not called? I can't even get the alert ('callback time!'). I thinked that my json could be broken, but firebug net console read and parse it very well, so i think is valid JSON.
I also tried to split up the function declaration from the getJSON request, but it's no use.
Any ideas? In two days I couldn't figure it out!