我有一段代码在IE浏览器中可以正常工作,但在Firefox浏览器中无法运行。我认为问题是我没有成功实现$('document').ready(function)
。我的JSON结构如下:[{"options":"smart_exp"},{"options":"user_intf"},{"options":"blahblah"}]。
如果有人能查看我的代码并帮助我正确实现它,我将非常感激。这是我的代码:
<html><head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2
/jquery.min.js"></script>
<script type="text/javascript" language="javascript">
$(document).ready(function() {
$.getJSON("http://127.0.0.1/conn_mysql.php", function (jsonData) {
$.each(jsonData, function (i, j) {
document.form1.fruits.options[i] = new Option(j.options);
});});
});
</script></head>
<body><form name="form1">
My favourite fruit is :
<select name="fruits" id="fruits" /></form></body>
</html>