Created
December 2, 2014 09:00
-
-
Save hanxiaomax/ea33f5cf072fdbd32eb3 to your computer and use it in GitHub Desktop.
关于getJSON的一点点小坑
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(function(){ | |
$("input:radio").change(function(){ | |
var selectedvalue = $("input[name='group']:checked").val(); | |
//使用getJSON会导致每次都从浏览器缓存里面加载json,ajax就可以实现动态的修改json并加载了 | |
$.ajax({ | |
type: "get", | |
url:'/static/select.json', | |
cache: false,//必须为false,否则同样会从缓存中加载 | |
dataType : "json", | |
success: function(data){ | |
$("#apply").empty(); | |
$.each(data,function() { | |
if (this.catagory==selectedvalue) | |
{ | |
$.each(this.subcatagory, function() { | |
$("#apply").append("<option value="+this.name+">" + this.name + "</option>"); | |
}); | |
}; | |
}); | |
} | |
}); | |
}); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(function(){ | |
$("input:radio").change(function(){ | |
var selectedvalue = $("input[name='group']:checked").val(); | |
$.getJSON($SCRIPT_ROOT+"/_getJSON",function(data){ | |
$("#apply").empty(); | |
$.each(data,function() { | |
if (this.catagory==selectedvalue) | |
{ | |
$.each(this.subcatagory, function() { | |
alert(this.name) | |
$("#apply").append("<option value="+this.name+">" + this.name + "</option>"); | |
}); | |
}; | |
}); | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment