<script>var music_arr = [
{ "id":"1",
"song":"黑色毛衣",
"singer":"周杰伦",
"special":"《专辑名称》",
"url":"<%=play_link_url(k)%>",
"lyric":
{
"type":"no",
"info":" 歌词" },
"stat":"0"
},
{
"id":"2",
"song":"白色风车",
"singer":"周杰伦",
"special":"《专辑名称》",
"url":"http://mp3.jayfan.com/jayfan1125/白色风车.mp3",
"lyric":
{
"type":"no",
"info":" 歌词" },
"stat":"0"
}];
</script>以上代码中的"id":"1" 和"id":"2" 中的部分怎么写成循环.我是在asp中用的.谢谢!!!
{ "id":"1",
"song":"黑色毛衣",
"singer":"周杰伦",
"special":"《专辑名称》",
"url":"<%=play_link_url(k)%>",
"lyric":
{
"type":"no",
"info":" 歌词" },
"stat":"0"
},
{
"id":"2",
"song":"白色风车",
"singer":"周杰伦",
"special":"《专辑名称》",
"url":"http://mp3.jayfan.com/jayfan1125/白色风车.mp3",
"lyric":
{
"type":"no",
"info":" 歌词" },
"stat":"0"
}];
</script>以上代码中的"id":"1" 和"id":"2" 中的部分怎么写成循环.我是在asp中用的.谢谢!!!
<%
For i = 1 To 10
Response.Write "{ "id":"1",
"song":"黑色毛衣",
"singer":"周杰伦",
"special":"《专辑名称》",
"url":" <%=play_link_url(k)%>",
"lyric":
{
"type":"no",
"info":" 歌词" },
"stat":"0"
}If i <> 10 Then Response.Write "," & vbCrLf
%> ];
</script> 具体写法就省略了
<%
For i = 1 To 10
Response.Write "{ "id":"1", "& vbCrLf
Response.Write ""song":"黑色毛衣", "& vbCrLf
Response.Write ""singer":"周杰伦", "& vbCrLf
Response.Write ""special":"《专辑名称》", "& vbCrLf
Response.Write ""url":"3", "& vbCrLf
Response.Write ""lyric": "& vbCrLf
Response.Write "{ "& vbCrLf
Response.Write ""type":"no","& vbCrLf
Response.Write ""info":" 歌词" }, "& vbCrLf
Response.Write ""stat":"0" "& vbCrLf
Response.Write "} "& vbCrLfIf i <> 10 Then Response.Write "," & vbCrLf
next%> ];
<%set rs=....
sql=....
rs.open sql,conn,1,1
if not rs.bof then
znum=rs.recordcount'取记录集,以备用
i=0
do while not rs.eof
Response.Write "{ ""id"":"""&rs("id")&""", "& vbCrLf
Response.Write """song"":"""&rs("id")&""", "& vbCrLf
Response.Write """singer"":"""&rs("id")&""", "& vbCrLf
Response.Write """special"":"""&rs("id")&""", "& vbCrLf
Response.Write """url"":""""&rs("id")&"""", "& vbCrLf
Response.Write """lyric"": "& vbCrLf
Response.Write "{ "& vbCrLf
Response.Write """type"":"""&rs("id")&""","& vbCrLf
Response.Write """info"":"""&rs("id")&""" }, "& vbCrLf
Response.Write """stat"":"""&rs("id")&""" "& vbCrLf
Response.Write "} "& vbCrLf
i=i+1
If i <> znum Then Response.Write "," & vbCrLf
rs.movenext
loop
set rs=nothing%>];
</script>
因为你双引号里有双引号,必须用转义
而ASP中的双引号转义是用2个双引号来做转义
双引号 可以用""或者chr(34) 转义.
需要细心.问题解决.
再次感谢chinmo
.
人力资源
<%
For i = 1 To 10
Response.Write "{ "id":"1",
"song":"黑色毛衣",
"singer":"周杰伦",
"special":"《专辑名称》",
"url":" <%=play_link_url(k)%>",
"lyric":
{
"type":"no",
"info":" 歌词" },
"stat":"0"
} If i <> 10 Then Response.Write "," & vbCrLf
%>
];
</script>