我有一个由数据库生成的表格。在数据库中,我有一个字符串,比如西班牙语,它将成为下调菜单中的选项。
那一刻,我的html看起来像:
<option value="Española">Española</option>
我使用这些值作为表格中需要发送 AJAX 请求的动态部分。
我可以看到,当使用 IE 时, 信头就像这样:
GET /collections/find_island?island_group=Espa�ola HTTP/1.1" 500 63206
何时应:
GET /collections/find_island/?island_group=Espa%C3%B1ola HTTP/1.1" 200 164
由其它浏览器生成。
我能不能在我的模板中找到这个输出:
<option value="Espa%C3%B1ola">Española</option>
任何帮助 非常感谢。
编辑:
我的形状:
def form(forms.Form):
...
island_group = forms.ModelChoiceField(
required=False,
label=ugettext_lazy( Island Group ),
initial=None,
queryset=Localityonline.objects.values_list( islandgroup , flat=True).distinct( islandgroup ).order_by( islandgroup ),
empty_label=ugettext_lazy("Not Specified"),
widget=forms.Select(attrs={"class": searchfield , "onChange": getIslandName() })
)
笔记本:
function getIslandName(lang) {
var islandGroup = document.getElementById("id_island_group").value;
if (islandGroup == ) {
// if Not Specified re-selected then set data to null and bypass updatePage()
var data = null;
update_select($( select[name=island_name] ), data);
}
else {
var url = "../collections/find_island?island_group=" + islandGroup;
request.open("GET", url, true);
request.onreadystatechange = updatePage;
request.send(null);
}
}