function find() { var F = "http://api.t.sohu.com/statuses/public_timeline.json "; $.getJSON(F, w); //前者为地址,后者为回调函数 } function w(M) { alert("created_at:" + M.created_at); }
Jquery function find() { var F = "http://api.t.sohu.com/statuses/public_timeline.json "; $.getJSON(F, w); //前者为地址,后者为回调函数 } function w(M) { alert("created_at:" + M.created_at); }
function getScipt(url){
var scirpttag = document.createElement("script");
scripttag.setAttribute("type","text/javascirpt");
scripttag.setAttribute("src",url);
document.getElementsByTagName("head")[0].appendChild(scirpttag);
}
getScipt("http://api.t.sohu.com/statuses/public_timeline.json");
这样你就可以访问从url中返回的json中的数据了
// 动态导入js
function include(src,encoding,fun)
{
var s = document.createElement('script');
s.type='text/javascript';
s.charset=encoding; //'gb2312';
s.src = src;
var tags =document.getElementsByTagName('head');
if(typeof(fun)=='function'){
if( document.all ){
s.onreadystatechange = function(){
if(/(complete|loaded)/.test(this.readyState)){
fun(); s.onreadystatechange = null; s.parentNode.removeChild(s);
}};
}else{
s.onload = function(){ fun(); s.onload = null; s.parentNode.removeChild(s); };
}
}
tags[0].appendChild(s);
};
{
var F = "http://api.t.sohu.com/statuses/public_timeline.json
";
$.getJSON(F, w); //前者为地址,后者为回调函数
}
function w(M)
{
alert("created_at:" + M.created_at);
}
function find()
{
var F = "http://api.t.sohu.com/statuses/public_timeline.json
";
$.getJSON(F, w); //前者为地址,后者为回调函数
}
function w(M)
{
alert("created_at:" + M.created_at);
}