通过js读取json,并在网页上显示出来 两种方式:一种是用js原声方法实现,一种是利用jquery框架实现json数据是urlJavaScriptJSON 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 你 url 是什么是否涉及到跨域 url是否支持跨域 你 url 是什么是否涉及到跨域 url是否支持跨域url是:http://fxinfo.api.fxhelper.cn/news/bignewnews.js 你网站的还是别人的?比人的需要做代理看这个http://bbs.csdn.net/topics/390526928 jQuery.support.cors = true; var url='http://fxinfo.api.fxhelper.cn/news/bignewnews.js'; var str=""; $.getJSON(url,function(json){ var n=json.length; for(var i=0;i<n;i++){ str += "<div>" + json[i].Value.strfrom + "</div>"; } document.getElementById('msg').innerHTML=str; }) $.getJSON("test.aspx", function (json) { alert(json[0].Key); });test.aspxusing System.Net; string str=""; string url = "http://fxinfo.api.fxhelper.cn/news/bignewnews.js"; using (WebClient client = new WebClient()) { client.Encoding = System.Text.UTF8Encoding.UTF8; str= client.DownloadString(url); } Response.Write(str); Response.End(); 不用回调么?我写了个看下<!doctype html><html xmlns="http://www.w3.org/1999/xhtml" > <head><meta charset="utf-8"><script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.8.0.js"></script><script type="text/javascript">$(document).ready(function(){ $("button").click(function(){ $.getJSON("http://fxinfo.api.fxhelper.cn/news/bignewnews.js?callback=?",function(data){ var s=""; $.each(data, function(i, item){ s +=item["go"]+"<br>"; }); $("#go").html(s); }); });});</script></head><body><button>开始</button><div id="go"></div></body></html> 不用回调么?我写了个看下<!doctype html><html xmlns="http://www.w3.org/1999/xhtml" > <head><meta charset="utf-8"><script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.8.0.js"></script><script type="text/javascript">$(document).ready(function(){ $("button").click(function(){ $.getJSON("http://fxinfo.api.fxhelper.cn/news/bignewnews.js?callback=?",function(data){ var s=""; $.each(data, function(i, item){ s +=item["go"]+"<br>"; }); $("#go").html(s); }); });});</script></head><body><button>开始</button><div id="go"></div></body></html>引用完JQuery后记得加一条jQuery.support.cors = true;允许跨站 不用回调么?我写了个看下<!doctype html><html xmlns="http://www.w3.org/1999/xhtml" > <head><meta charset="utf-8"><script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.8.0.js"></script><script type="text/javascript">$(document).ready(function(){ $("button").click(function(){ $.getJSON("http://fxinfo.api.fxhelper.cn/news/bignewnews.js?callback=?",function(data){ var s=""; $.each(data, function(i, item){ s +=item["go"]+"<br>"; }); $("#go").html(s); }); });});</script></head><body><button>开始</button><div id="go"></div></body></html>引用完JQuery后记得加一条jQuery.support.cors = true;允许跨站不是所有浏览器都支持jQuery.support.cors = true; 不用回调么?我写了个看下<!doctype html><html xmlns="http://www.w3.org/1999/xhtml" > <head><meta charset="utf-8"><script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.8.0.js"></script><script type="text/javascript">$(document).ready(function(){ $("button").click(function(){ $.getJSON("http://fxinfo.api.fxhelper.cn/news/bignewnews.js?callback=?",function(data){ var s=""; $.each(data, function(i, item){ s +=item["go"]+"<br>"; }); $("#go").html(s); }); });});</script></head><body><button>开始</button><div id="go"></div></body></html>引用完JQuery后记得加一条jQuery.support.cors = true;允许跨站不是所有浏览器都支持jQuery.support.cors = true; 我写的对吗?有问题么?我的看不了啊 不支持 jsonp 所以你要用 在7楼给你的方法啊不是所有浏览器都支持jQuery.support.cors = true; 不支持 jsonp 所以你要用 在7楼给你的方法啊不是所有浏览器都支持jQuery.support.cors = true; 我知道不是所有的浏览器都支持,但是我写的也是有问题的,你知道怎么改么? 不支持 jsonp 所以你要用 在7楼给你的方法啊不是所有浏览器都支持jQuery.support.cors = true; 我知道不是所有的浏览器都支持,但是我写的也是有问题的,你知道怎么改么?楼主很是坚持啊<html xmlns="http://www.w3.org/1999/xhtml" > <head><script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.8.0.js"></script><script type="text/javascript">jQuery.support.cors = true;$(document).ready(function () { $("button").click(function () { $.getJSON("http://fxinfo.api.fxhelper.cn/news/bignewnews.js", function (data) { var s = ""; $.each(data, function (i, item) { s += item.Value["strtitle"] + "<br>"; }); $("#go").html(s); }); });});</script></head><body><button>开始</button><div id="go"></div></body></html> 不支持 jsonp 所以你要用 在7楼给你的方法啊不是所有浏览器都支持jQuery.support.cors = true; 我知道不是所有的浏览器都支持,但是我写的也是有问题的,你知道怎么改么?楼主很是坚持啊<html xmlns="http://www.w3.org/1999/xhtml" > <head><script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.8.0.js"></script><script type="text/javascript">jQuery.support.cors = true;$(document).ready(function () { $("button").click(function () { $.getJSON("http://fxinfo.api.fxhelper.cn/news/bignewnews.js", function (data) { var s = ""; $.each(data, function (i, item) { s += item.Value["strtitle"] + "<br>"; }); $("#go").html(s); }); });});</script></head><body><button>开始</button><div id="go"></div></body></html>那个http://fxinfo.api.fxhelper.cn/news/bignewnews.js后面不用加?callback=?吗? 不支持 jsonp 所以你要用 在7楼给你的方法啊不是所有浏览器都支持jQuery.support.cors = true; 我知道不是所有的浏览器都支持,但是我写的也是有问题的,你知道怎么改么?楼主很是坚持啊<html xmlns="http://www.w3.org/1999/xhtml" > <head><script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.8.0.js"></script><script type="text/javascript">jQuery.support.cors = true;$(document).ready(function () { $("button").click(function () { $.getJSON("http://fxinfo.api.fxhelper.cn/news/bignewnews.js", function (data) { var s = ""; $.each(data, function (i, item) { s += item.Value["strtitle"] + "<br>"; }); $("#go").html(s); }); });});</script></head><body><button>开始</button><div id="go"></div></body></html>非常感谢大神,但是我还是想知道为什么要加.Value["strtitle"]?这是什么意思啊?还有那个为什么不用加?callback=?回调呢? 不支持 jsonp 所以你要用 在7楼给你的方法啊不是所有浏览器都支持jQuery.support.cors = true; 我知道不是所有的浏览器都支持,但是我写的也是有问题的,你知道怎么改么?楼主很是坚持啊<html xmlns="http://www.w3.org/1999/xhtml" > <head><script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.8.0.js"></script><script type="text/javascript">jQuery.support.cors = true;$(document).ready(function () { $("button").click(function () { $.getJSON("http://fxinfo.api.fxhelper.cn/news/bignewnews.js", function (data) { var s = ""; $.each(data, function (i, item) { s += item.Value["strtitle"] + "<br>"; }); $("#go").html(s); }); });});</script></head><body><button>开始</button><div id="go"></div></body></html>非常感谢大神,但是我还是想知道为什么要加.Value["strtitle"]?这是什么意思啊?还有那个为什么不用加?callback=?回调呢?那个为什么加.Value["strtitle"]我知道了 ,但是那个为什么不用加?callback=?我还是不明白?还有用js原生方法,该怎么做呢?可以提分 function(e)中的参数“e”是什么意思 关于javascript 性能测试的问题 据说能散三百分,我来试试:) 超简单问题 救命!!! 在本机可以正确执行,怎么上传到网上就触发不了啊!(关于处理ie关闭时的问题) 求助,关于IFRAME的问题!谢谢。 谁能帮我把这个帖子找回来啊? 浏览器缓存怎么清除 JavaScript如何正确实时显示输入的字母? 被js伤透了心 引入jquery报NetworkError: 400 Bad Request 鼠标移入第一个图片,然后快速移动第二个图片,为什么会抖了一下,肿么解决??
是否涉及到跨域 url是否支持跨域
是否涉及到跨域 url是否支持跨域url是:http://fxinfo.api.fxhelper.cn/news/bignewnews.js
var url='http://fxinfo.api.fxhelper.cn/news/bignewnews.js';
var str="";
$.getJSON(url,function(json){
var n=json.length;
for(var i=0;i<n;i++){
str += "<div>" + json[i].Value.strfrom + "</div>";
}
document.getElementById('msg').innerHTML=str;
})
alert(json[0].Key);
});test.aspx
using System.Net;
string str="";
string url = "http://fxinfo.api.fxhelper.cn/news/bignewnews.js"; using (WebClient client = new WebClient())
{
client.Encoding = System.Text.UTF8Encoding.UTF8;
str= client.DownloadString(url);
}
Response.Write(str);
Response.End();
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<meta charset="utf-8">
<script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.8.0.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("button").click(function(){
$.getJSON("http://fxinfo.api.fxhelper.cn/news/bignewnews.js?callback=?",function(data){
var s="";
$.each(data, function(i, item){
s +=item["go"]+"<br>";
});
$("#go").html(s);
});
});
});
</script>
</head><body>
<button>开始</button>
<div id="go">
</div></body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<meta charset="utf-8">
<script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.8.0.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("button").click(function(){
$.getJSON("http://fxinfo.api.fxhelper.cn/news/bignewnews.js?callback=?",function(data){
var s="";
$.each(data, function(i, item){
s +=item["go"]+"<br>";
});
$("#go").html(s);
});
});
});
</script>
</head><body>
<button>开始</button>
<div id="go">
</div></body>
</html>引用完JQuery后记得加一条
jQuery.support.cors = true;
允许跨站
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<meta charset="utf-8">
<script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.8.0.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("button").click(function(){
$.getJSON("http://fxinfo.api.fxhelper.cn/news/bignewnews.js?callback=?",function(data){
var s="";
$.each(data, function(i, item){
s +=item["go"]+"<br>";
});
$("#go").html(s);
});
});
});
</script>
</head><body>
<button>开始</button>
<div id="go">
</div></body>
</html>引用完JQuery后记得加一条
jQuery.support.cors = true;
允许跨站
不是所有浏览器都支持
jQuery.support.cors = true;
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<meta charset="utf-8">
<script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.8.0.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("button").click(function(){
$.getJSON("http://fxinfo.api.fxhelper.cn/news/bignewnews.js?callback=?",function(data){
var s="";
$.each(data, function(i, item){
s +=item["go"]+"<br>";
});
$("#go").html(s);
});
});
});
</script>
</head><body>
<button>开始</button>
<div id="go">
</div></body>
</html>引用完JQuery后记得加一条
jQuery.support.cors = true;
允许跨站
不是所有浏览器都支持
jQuery.support.cors = true; 我写的对吗?有问题么?我的看不了啊
jQuery.support.cors = true;
jQuery.support.cors = true; 我知道不是所有的浏览器都支持,但是我写的也是有问题的,你知道怎么改么?
jQuery.support.cors = true; 我知道不是所有的浏览器都支持,但是我写的也是有问题的,你知道怎么改么?楼主很是坚持啊<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.8.0.js"></script>
<script type="text/javascript">
jQuery.support.cors = true;
$(document).ready(function () {
$("button").click(function () {
$.getJSON("http://fxinfo.api.fxhelper.cn/news/bignewnews.js", function (data) {
var s = "";
$.each(data, function (i, item) {
s += item.Value["strtitle"] + "<br>";
});
$("#go").html(s);
});
});
});
</script>
</head><body>
<button>开始</button>
<div id="go">
</div></body>
</html>
jQuery.support.cors = true; 我知道不是所有的浏览器都支持,但是我写的也是有问题的,你知道怎么改么?楼主很是坚持啊<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.8.0.js"></script>
<script type="text/javascript">
jQuery.support.cors = true;
$(document).ready(function () {
$("button").click(function () {
$.getJSON("http://fxinfo.api.fxhelper.cn/news/bignewnews.js", function (data) {
var s = "";
$.each(data, function (i, item) {
s += item.Value["strtitle"] + "<br>";
});
$("#go").html(s);
});
});
});
</script>
</head><body>
<button>开始</button>
<div id="go">
</div></body>
</html>
那个http://fxinfo.api.fxhelper.cn/news/bignewnews.js后面不用加?callback=?吗?
jQuery.support.cors = true; 我知道不是所有的浏览器都支持,但是我写的也是有问题的,你知道怎么改么?楼主很是坚持啊<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.8.0.js"></script>
<script type="text/javascript">
jQuery.support.cors = true;
$(document).ready(function () {
$("button").click(function () {
$.getJSON("http://fxinfo.api.fxhelper.cn/news/bignewnews.js", function (data) {
var s = "";
$.each(data, function (i, item) {
s += item.Value["strtitle"] + "<br>";
});
$("#go").html(s);
});
});
});
</script>
</head><body>
<button>开始</button>
<div id="go">
</div></body>
</html>
非常感谢大神,但是我还是想知道为什么要加.Value["strtitle"]?这是什么意思啊?还有那个为什么不用加?callback=?回调呢?
jQuery.support.cors = true; 我知道不是所有的浏览器都支持,但是我写的也是有问题的,你知道怎么改么?楼主很是坚持啊<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.8.0.js"></script>
<script type="text/javascript">
jQuery.support.cors = true;
$(document).ready(function () {
$("button").click(function () {
$.getJSON("http://fxinfo.api.fxhelper.cn/news/bignewnews.js", function (data) {
var s = "";
$.each(data, function (i, item) {
s += item.Value["strtitle"] + "<br>";
});
$("#go").html(s);
});
});
});
</script>
</head><body>
<button>开始</button>
<div id="go">
</div></body>
</html>
非常感谢大神,但是我还是想知道为什么要加.Value["strtitle"]?这是什么意思啊?还有那个为什么不用加?callback=?回调呢?
那个为什么加.Value["strtitle"]我知道了 ,但是那个为什么不用加?callback=?我还是不明白?
还有用js原生方法,该怎么做呢?可以提分