<script language="javascript" type="text/javascript">
            var yuser='<%=ChatName%>';
            var ysuser='<%=Request.QueryString["id"]%>';
window.setInterval("liaotian('"+ysuser+"','"+yuser+"',get_chat)",2000);

function get_chat(response)
{
//updatechat();

if (response.value != null)
{

var ds = response.value;
    
var htmlstr="<table width=100% border=0 cellpadding=4 cellspacing=0>";  
for(var i=0; i<ds.Tables[0].Rows.length; i++)
     {
     htmlstr+="<tr>"; 
     var time_table=ds.Tables[0].Rows[i].setime.toLocaleString().replace("年","-").replace("月","-").replace("日","");
       var sname_table=ds.Tables[0].Rows[i].seadname;
       var suser_table=ds.Tables[0].Rows[i].senduser;
      
       var aname_table=ds.Tables[0].Rows[i].atpname;
       var auser_table=ds.Tables[0].Rows[i].atpuser;
      
       var content_table=ds.Tables[0].Rows[i].content.replace('\n','<br>').replace(' ','&nbsp;&nbsp;');
       var id=ds.Tables[0].Rows[i].id;
      
       htmlstr+="<td>[<a href=javascript:void(0) onclick=parent.setuser('"+suser_table+"','"+sname_table+"')><font color=#FF00F7>"+sname_table+"</font></a>]对[<a href=javascript:void(0) onclick=parent.setuser('"+auser_table+"','"+aname_table+"')><font color=#0000FF>"+aname_table+"</font></a>]说:"+content_table+"<font color=#FF0000>("+time_table+")</font></td></tr>";
       //htmlstr=htmlstr+"</tr>";
     }
     htmlstr+="</TABLE>";
     document.getElementById('Tables_chat').innerHTML=htmlstr;
     //window.Form1.content.value='';
     //window.Form1.content.focus();
     parent.Form1.btn_AddCity.value='发送(Enter)';
    parent.Form1.btn_AddCity.disabled=false;
   
    document.getElementById('show').style.display='none'; 
     }
    
              
               parent.rform.scroll(0,1000);
    
}
function liaotian(ysuser,yuser,get_chat)
{
var gcontent = document.getElementById("liaotianContent");
            var Action='action=Post&Method='+'2'+'&ysuser='+ysuser+'&yuser='+escape(yuser)+'&get_chat='+get_chat;   
                      var options={ 
                      method:'get', 
                      parameters:Action, 
                      onComplete:function(transport) 
                      { 
                           var returnvalue=transport.responseText;             
                          
                              gcontent.innerHTML=returnvalue; 
                         
                      } 
                   }; 
               new  Ajax.Request('ajax.aspx?no-cache='+Math.random(),options);
}
</script>
我自己定义了function liaotian去请求ajax.aspx里面的方法,var gcontent = document.getElementById("liaotianContent");返回值应该用在什么地方呢?刚学了2天不是很懂

解决方案 »

  1.   

    为什么要去asp板块问? 不都是js代码吗
      

  2.   

    不是很懂你要問的意思,
    returnvalue就是你的回傳值啊。
      

  3.   

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>无标题文档</title>
    <script>
    function test(){
    return "这个是测试";

    }

    function test2(){
    alert(test());//调用上面的测试函数

    }</script>
    </head>
    <body>
    <input type="button" onclick="test2()" value="测试"/>
    </body>
    </html>直接返回