注册 登录
编程论坛 JavaScript论坛

getJson问题

yaopeng0418 发布于 2010-10-21 13:24, 974 次点击
返回数据:response.Write ("{cont:"&escape(str)&",page:"&escape(str1)&"}")
方法为:
function check(page){

        $.getJSON("conn4.asp?page="+page+"&name="+escape(document.getElementById("code").value)+"&name1"+escape(document.getElementById("fname").value),function(json){
                                        alert(json);      
                            $("#layer1").append(unescape(json["cont"]));                  
                            $("#layer").innerHTML=unescape(json["page"]);                  
                                       
                                              });                  
                    
                           }
可是没有显示出来,请教
9 回复
#2
gupiao1752010-10-21 13:37
conn4.asp文件是怎么样的???

请提供完整些的代码吧!
#3
yaopeng04182010-10-21 13:54
If rs.eof Then
Else
    rs.pagesize=20
    page=request("page")
    If Not Isnumeric(page) or page="" Then
      page=1
    else
      page=cint(page)
    End if
    if page<1 then page=1
    if page>rs.pagecount then page=rs.pagecount
    rs.AbsolutePage = page
    for i=1 to rs.pagesize
  if rs("online")=true then

cls=""
else

cls="filter:gray"
end if
    '******************下面是你要显示的******************'
   
 str=str&"<tr>"
      str=str&"<td  height='37' ><div align='left'>&nbsp;<img src="&rs("hpicture")&" class="&cls&" style='border:1px solid #B1C8FF;cursor:pointer;'  onMouseOut='this.width=40;this.height=40;' onMouseOver='DrawImage(this)' width='40' height='40'></div></td>"
      str=str&"<td><div align='center'>"&rs("code")&"</div></td>"
      str=str&"<td><div align='center'>"&rs("username")&"</div></td>"
      str=str&"<td><div align='center'>"&rs("age")&"</div></td>"
        str=str&"<td ><div align='center'>"&rs("address")&"</div></td>"
      str=str&"<td><div align='center'><a onclick='window.open('xiangxi.asp?name='+escape("&rs("code")&"),'_blank','toolbar=no,width=500,height=480');' style='color:#666666; font-weight: bold; text-decoration:underline'>详细资料</a></div></td>"
      str=str&"<td><div align='left'><a href='#' onClick='findfri(this.id)' id="&rs("code")&"  style='color:#333333'>加为好友</a></div></td>"
    str=str&"</tr>"
    str=str&"<tr style='border:1px solid #CCCCCC;'>"
      str=str&"<td  height='15' colspan='8'><hr size='1'  noshade ></td>"
    str=str&"</tr>"
    '******************上面是你要显示的******************'
    rs.movenext
    if rs.eof then
      Exit For
    End if
    next
end if


str1="共 "&rs.recordcount&" 条&nbsp;&nbsp;20 条/页 <a href=""javascript:check(1);"">首页</a><a href=""javascript:check("&page-1&");"">上一页</a>"
   

      ' response.Write("<a href="&Request.ServerVariables("URL")&">首页</a>")

 if page>2 then s1=page-2 else s1=1
if page<rs.pagecount-2 then s2=page+2 else s2=rs.pagecount
if s1>=2 then response.write ".."
for j=s1 to s2
   if j=page then
   str1=str1&"<a href=""javascript:check("&j&");""><font color=#ff0000>"&j&"</font></a>&nbsp;"
   else
    str1=str1&"<a href=""javascript:check("&j&");"">"&j&"</a>&nbsp;"
   end if
next
if s2<rs.pagecount then str1=str1&".."
'rs.close

     'response.Write("<a href="&Request.ServerVariables("URL")&"?page="&rs.pagecount


   
str1=str1&"<a href=""javascript:check("&page+1&");"">下一页</a>"
str1=str1&"<a href=""javascript:check("&rs.pagecount&");"">末页</a>"
#4
gupiao1752010-10-21 19:59
你的代码第一行怎么是:
If rs.eof Then
那之前的rs呢??
#5
yaopeng04182010-10-22 06:16
开头没错,就是怎么获取json数据出错了
#6
gupiao1752010-10-22 07:41
麻烦楼主把代码提供完整些吧,那些RS变量不会让测试的人自己手写吧!
#7
yaopeng04182010-10-22 08:25
<%
'  *** Recordset Stats, Move To Record, and Go To Record: declare stats variables

Set rs= Server.CreateObject("ADODB.Recordset")
rs.open "SELECT username,code,hpicture,age,sex,online,sign,address FROM Userinfo ORDER BY submit_date DESC",conn,1,3
'"select top 12 *  from Userinfo where pageindex='"&request.QueryString("page")&"' order by order by submit_date DESC";

        
           
 '             = "select * from (select top 20 * from (select top " + 20 * pageindex + " " + field + " from Userinfo where " + strwhere + ") a order by " + field2 + " desc)
        
        
dim fqys,errc,i
dim nothis(19)
fqys = request.Form("textfield")
qq=request.Form("textfield2")
nothis(0)="net user"

nothis(1)="xp_cmdshell"

nothis(2)="/add"

nothis(3)="exec%20master.dbo.xp_cmdshell"

nothis(4)="net localgroup administrators"

nothis(5)="select"

nothis(6)="count"

nothis(7)="asc"

nothis(8)="char"

nothis(9)="mid"

nothis(10)="'"

nothis(11)=":"

nothis(12)=""""

nothis(13)="insert"

nothis(14)="delete"

nothis(15)="drop"

nothis(16)="truncate"

nothis(17)="from"

nothis(18)="%"

nothis(19)="@"

errc=false

dim sa
sa=""
for each items in request.form
for i= 0 to ubound(nothis)

if instr(unescape(request.form(items)),nothis(i))<>0 then
errc=true
sa=  nothis(i) + "," + sa
end if
next


next
if errc then
response.Write ("<script>alert('输入:含非法字符:'&'"&sa&"')</script>")
else
 if request.QueryString("name")<>"" then
Set rs= Server.CreateObject("ADODB.Recordset")
rs.open "SELECT username,code,hpicture,age,sex,online,sign,address FROM Userinfo WHERE code='"&request.QueryString("name")&"' union SELECT username,code,hpicture,age,sex,online,sign,address FROM Userinfo WHERE code LIKE '%"&request.QueryString("name")&"%'",conn,1,3
if rs.EOF then


end if
end if

if request.QueryString("name1")<>"" then
Set rs= Server.CreateObject("ADODB.Recordset")
rs.open "SELECT username,code,hpicture,age,sex,online,sign,address FROM Userinfo WHERE username='"&request.QueryString("name1")&"' union SELECT username,code,hpicture,age,sex,online,sign,address FROM Userinfo WHERE username LIKE '%"&request.QueryString("name1")&"%' ",conn,1,3
if rs.EOF then

end if
end if
end if
%>
#8
hugeannex2010-11-12 13:16
$("#layer1").append(unescape(json["cont"]));                  
$("#layer").innerHTML=unescape(json["page"]);

改为:
$("#layer1").append(unescape(json.cont));                  
$("#layer").html(unescape(json.page));
#9
sclorg2010-11-18 17:27
alert出来什么呢,你把json字符串转化为json对象来处理了吗
1