下面是编程之家 jb51.cc 通过网络收集整理的代码片段。
编程之家小编现在分享给大家,也给大家做个参考。
//查询公告数据 function recentpost(){ $.getJSON(cmsUrl+"/post/recentpost.json?jsoncallback=?",{count:count,categoryid:categoryid},function(data){ // }); }
jQuery.getJSON(url,[data],[callback])
概述
参数
url,[callback]String,Map,FunctionV1.0
示例
描述:
HTML 代码: @H_502_34@
<div id="images"></div>
jQuery 代码: @H_502_34@
$.getJSON("http://api.flickr.com/services/Feeds/photos_public.gne?tags=cat&tagmode=any&format
=json&jsoncallback=?",function(data){
$.each(data.items,function(i,item){
$("<img/>").attr("src",item.media.m).appendTo("#images");
if ( i == 3 ) return false;
});
});
描述:
jQuery 代码: @H_502_34@
$.getJSON("test.js",function(json){
alert("JSON Data: " + json.users[3].name);
});
描述:
jQuery 代码: @H_502_34@
<div id="images"></div>
$.getJSON("http://api.flickr.com/services/Feeds/photos_public.gne?tags=cat&tagmode=any&format
=json&jsoncallback=?",function(data){
$.each(data.items,function(i,item){
$("<img/>").attr("src",item.media.m).appendTo("#images");
if ( i == 3 ) return false;
});
});
描述:
jQuery 代码: @H_502_34@
$.getJSON("test.js",function(json){
alert("JSON Data: " + json.users[3].name);
});
描述:
jQuery 代码: @H_502_34@
$.getJSON("test.js",{ name: "John",time: "2pm" },function(json){ alert("JSON Data: " + json.users[3].name); });
@RequestMapping(value = "recentpost") public void recentPost(Integer categoryid,String jsoncallback,Integer count,Model model,HttpServletResponse response) { if (categoryid == null) { categoryid = DEFAULT_CATEGORY; } List<Post> list = postService.listRecent(categoryid,count); // JSONObject json = new JSONObject(); // json.put("list",list); // String str=json.toJSONString(); // model.addAttribute("callback",list); String str = JSONObject.toJSONString(list); str = jsoncallback + "(" + str + ")"; super.returnMessage(response,str); }
以上是编程之家(jb51.cc)为你收集整理的全部代码内容,希望文章能够帮你解决所遇到的程序开发问题。
如果觉得编程之家网站内容还不错,欢迎将编程之家网站推荐给程序员好友。