為啥ie下可以,火狐不行呢
為啥ie下可以,火狐不行呢,火狐顯示未定義。。。
$(function () {
? ?$("#btnShow").on("click", function () {
? ? ? ?var $this = $(this);
? ? ? ?$.getJSON("data/sport.json", function (data) {
? ? ? ? ? ?$this.attr("disabled", "true");
? ? ? ? ? ?$.each(data, function (index,sport) {
? ? ? ? ? ? ? $("ul").append('<li>'+sport["name"]+"</li>");
? ? ? ? ? ?});
? ? ? ?})
? ?});
})
[{"name":"3"},{"name":"5"},{"name":"5"}]
2017-06-08
搜了一段瀏覽器兼容代碼,加上就可以了,
function?gethttp(sid,?url)?{??
????var?xmlHttp;??
????if?(window.ActiveXObject)?{??
????????xmlHttp?=?new?ActiveXObject("Microsoft.XMLHTTP");??
????}??
????else?if?(window.XMLHttpRequest)?{??
????????xmlHttp?=?new?XMLHttpRequest();??
????}??
??
????xmlHttp.onreadystatechange?=?function()?{??
????????if?(xmlHttp.readyState?==?4)?{??
????????????document.getElementById(sid).innerHTML?=?xmlHttp.responseText;??
????????}??
????}??
??
????xmlHttp.open("POST",?url,?true);??
????xmlHttp.send(null);??
}?