我正在尝试根据外部html文件中第一个下拉列表的值填充第二个下拉列表,该文件仅填充选项。
外部文件示例:
<option value="Bedfordshire">Bedfordshire</option>
<option value="Berkshire">Berkshire</option>
<option value="Buckinghamshire">Buckinghamshire</option>
第一个下拉值的示例:
<select>
<option value="GB">UNITED KINGDOM</option> //option to load drop-GB.html
<option value="US">UNITED STATES</option> //option to load drop-US.html
</select>
在FF / Safari / Chrome中一切正常但在IE或iPad中根本没用?
var $shipcountry = $('#ShippingCountry');
$ShippingStateSelect = $('#ShippingStateSelect');
$ShippingStateSelect.load('drop-GB.html'); //pre load default list
$shipcountry.change(function () {
var countryName = $shipcountry.val();
$.ajax({
type: 'GET',
url: 'drop-' + countryName + '.html',
success: function (msg) {
$ShippingStateSelect.load('drop-' + countryName + '.html');
//fire other events on page
},
error: function (msg) {
$ShippingStateSelect.hide();
//show error message here
},
});
});
答案 0 :(得分:1)
你没有对传入的HTML进行排序,因为它不是“纯粹的”元素,IE浏览器失败而Firefox / Chrome等尝试修复它。
您的drop-US.html包含HTML结构,如
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<!-- BC_OBNW -->
<head>
<title>drop-US</title>
<link href="/StyleSheets/ModuleStyleSheets.css" type="text/css" rel="StyleSheet" />
<script type="text/javascript">var jslang='EN';</script>
</head>
然后尝试插入到选择框中。
所以你应该在ajax请求中过滤掉它,或者在源代码中删除它。 :)