我正在尝试使用JQUERY每10秒重新加载一个JSON文件.
该页面位于:http://moemonty.com/chirp/chirp.html
守则在这里:
<html>
<head>
<title>the title</title>
<!-- included Jquery Library -->
<script type="text/javascript" src="./js/jquery-1.4.2.js"></script>
<!-- jquery library -->
</head>
<body>
<script>
$.ajaxSetup({ cache: false }); //disallows cachinge, so information should be new
function loadChirp(){ //start function
var url = "http://www.chirpradio.org/json";
$.getJSON("http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20json%20where%20url%3D%22"+url+"%22&format=json&callback=?",
function(data){
console.log(data.query.results.json);
document.write('The artist is: ' + data.query.results.json.artist + '<br/><br/>');
document.write('The artist is: ' + data.query.results.json["record-label"] + '<br/><br/>' );
document.write('The album is: ' + data.query.results.json.album + '<br/><br/>');
document.write('The record label is: ' + data.query.results.json["record-label"] + …Run Code Online (Sandbox Code Playgroud) 我正在尝试更改元素的ID:
http://moemonty.com/chirp/CHIRP-JSON-test.html
通过使用此行:
$('.databaseID').attr('id', 'test');
Run Code Online (Sandbox Code Playgroud)
我想更改此行的id以进行测试,因此我可以继续通过字符串和JSON数据中的变量进行预修复.但就目前而言,我只是想看看我是否可以在此行用test替换它:
<li class="databaseID" id="np-44701">
Run Code Online (Sandbox Code Playgroud)
提前致谢.