关于JSONP跨域访问的问题_JAVA_编程开发_程序员俱乐部

中国优秀的程序员网站程序员频道CXYCLUB技术地图
热搜:
更多>>
 
您所在的位置: 程序员俱乐部 > 编程开发 > JAVA > 关于JSONP跨域访问的问题

关于JSONP跨域访问的问题

 2012/3/17 15:26:30  liuguihua0823  程序员俱乐部  我要评论(0)
  • 摘要:服务器返回的数据格式:dynamicData({"items":[{"title":"新闻1","publishTime":"2012-03-1510:53:30","linkUrl":"/zcms/Docs/news/5/html/5521186/20120315105319504.shtml"},{"title":"新闻2","publishTime":"2012-03-1510:53:30","linkUrl"
  • 标签:问题 JSON JS

服务器返回的数据格式:

dynamicData({
    "items": [
        {
            "title": "新闻1",
            "publishTime": "2012-03-15 10:53:30",
            "linkUrl": "/zcms/Docs/news/5/html/5521186/20120315105319504.shtml"
        },
        {
            "title": "新闻2",
            "publishTime": "2012-03-15 10:53:30",
            "linkUrl": "/zcms/Docs/news/5/html/5521186/20120315105305222.shtml"
        },
        {
            "title": "新闻3",
            "publishTime": "2012-03-15 09:47:28",
            "linkUrl": "/zcms/Docs/news/5/html/5521186/20120315094709368.shtml"
        }
    ]
})

?

页面的调用方法为:

<script type="text/javascript">
	function dynamicData(data){
		$.each(data.items, function(i, v){
			alert(v.title+"  "+v.linkUrl+"  "+v.publishTime);
		});
	}		
</script>
<script type="text/javascript" src="请求服务器返回数据的地址"></script>
发表评论
用户名: 匿名