惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

K
Kaspersky official blog
云风的 BLOG
云风的 BLOG
IT之家
IT之家
T
The Blog of Author Tim Ferriss
C
Check Point Blog
N
Netflix TechBlog - Medium
宝玉的分享
宝玉的分享
T
Tailwind CSS Blog
G
Google Developers Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
F
Fortinet All Blogs
D
DataBreaches.Net
The Register - Security
The Register - Security
L
LINUX DO - 最新话题
W
WeLiveSecurity
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
V2EX - 技术
V2EX - 技术
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
小众软件
小众软件
F
Full Disclosure
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
I
InfoQ
S
Secure Thoughts
TaoSecurity Blog
TaoSecurity Blog
MyScale Blog
MyScale Blog
AI
AI
Recent Announcements
Recent Announcements
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Hugging Face - Blog
Hugging Face - Blog
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
C
CXSECURITY Database RSS Feed - CXSecurity.com
V
Vulnerabilities – Threatpost
NISL@THU
NISL@THU
SecWiki News
SecWiki News
Cisco Talos Blog
Cisco Talos Blog
H
Heimdal Security Blog
Y
Y Combinator Blog
N
News | PayPal Newsroom
P
Privacy International News Feed
美团技术团队
Attack and Defense Labs
Attack and Defense Labs
D
Docker
PCI Perspectives
PCI Perspectives
Webroot Blog
Webroot Blog
A
About on SuperTechFans
A
Arctic Wolf
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
MongoDB | Blog
MongoDB | Blog
T
Threat Research - Cisco Blogs

博客园 - 优雅小猪

xp远程桌面登录 w3c的web标准校验工具 最小高度的实现 - 优雅小猪 - 博客园 div左右排版 - 优雅小猪 - 博客园 网页上运行代码和复制代码 - 优雅小猪 - 博客园 asp.net上传多个文件 - 优雅小猪 - 博客园 div vertical-align不起作用解决办法 - 优雅小猪 - 博客园 parentNode、parentElement,childNodes、children web后台运行任务(zz) 两个div,一个左右排列不换行(zz:http://www.cnblogs.com/circlesport/archive/2007/03/15/676261.html) - 优雅小猪 - 博客园 控制web页面的某块是否显示出来 - 优雅小猪 - 博客园 SVN的建立配置和简单使用 用<%if()%>控制页面某些部分是否可见 - 优雅小猪 - 博客园 placeholder LiteralControl从后台生成前台控件 - 优雅小猪 - 博客园 鼠标移入移出某个元素,元素背景变化 获得汉字的拼音首字母以及整个拼音 javascript同名函数 错误配置 Title换行
xmlhttp调用后台 - 优雅小猪 - 博客园
优雅小猪 · 2010-04-01 · via 博客园 - 优雅小猪

代码

    <script language="javascript" type="text/javascript">
         
        
function CallServer(url) {//            xml = new ActiveXObject("Microsoft.XMLHTTP");
//
            var post = "";
//
            xml.open("POST", url, false);
//
            xml.setrequestheader("content-length", post.length);
//
            xml.setrequestheader("content-type", "application/x-www-form-urlencoded");
//
            xml.send(post);
//
            var res = unescape(xml.responseText);
//
            return res

            xmlHttp 
= GetXmlHttpObject();
            
if (!xmlHttp || xmlHttp == null) {
                alert(
'browser does not support http request')
                
return;
            }
            xmlHttp.open(
"GET", url, false);
            xmlHttp.send(
null);
            
var res = unescape(xmlHttp.responseText);
            
return res
        }
function CallServerAsy(url, ID) 
        {
            xmlHttp 
= GetXmlHttpObject();
            
if (!xmlHttp || xmlHttp == null) {
                alert(
'browser does not support http request')
                
return;
            }
//xmlHttp.onreadystatechange = stateChanged;
           //xmlHttp.onreadystatechange = stateChanged(ID);
            xmlHttp.onreadystatechange =  function() { stateChanged(ID) }; 
            xmlHttp.open(
"GET", url, true);
            xmlHttp.send(
null);
          
        }
    
    
        
var xmlHttp;
        
function showHint(str) 
        {
            
if (str.length == 0) {
                document.getElementById(
"TextBoxHint").innerHTML = "";
                
return;
            }
var url = "LastNameLookup.aspx"
            url 
= url + "?q" + str;

            document.getElementById(

"TextBoxHint").innerHTML = "正在处理……";//同步调用
            //document.getElementById("TextBoxHint").innerHTML = CallServer(url);
            
            
//异步调用
            CallServerAsy(url, "TextBoxHint")
        }
function stateChanged(ID) 
        {
            
var OK = 200;
            
if ((xmlHttp.readyState == 4 || xmlHttp.readyState == "complete")
                
&& xmlHttp.status == OK) {      
                document.getElementById(ID).innerHTML 
= xmlHttp.responseText;            
            }
        }
function GetXmlHttpObject(hander) {
            
var objXMLHttp = null;
            
if (window.XMLHttpRequest) {
                
try {
              
                   objXMLHttp 
= new XMLHttpRequest();
                }
                
catch(e)
                {
                }
            }
            
else if(window.ActiveXObject)
            {
                
try {
                   
                   objXMLHttp 
= new ActiveXObject("Microsoft.XMLHTTP");
                   
               }
               
catch(e)
               {
               }
            }
            
return objXMLHttp;
        }
    
</script>

代码

<div>
       
<h1>Lookup</h1>
       
       
<b>Last name:</b><asp:TextBox ID="TextBox1" runat="server" onkeyup="showHint(this.value)"></asp:TextBox>
       
       
<p><b><i>Names: </i></b>&nbsp;<span id="TextBoxHint"></span></p>
       
    
</div>

LastNameLookup.aspx后台:

代码

                System.Threading.Thread.Sleep(10000);
                
string queryLastName = Request.QueryString.Get(0).ToString();
                
string returnString = "";
                returnString 
= "<select size=1>";
                returnString 
+= "<option>111</option>";
                returnString 
+= "<option>222</option>";
                returnString 
+= "<option>333</option>";
                returnString 
+= "<option>444</option>";
                returnString 
+= "<option>555</option>";
                returnString 
+= "</select>";
            
    Response.Write(returnString);
                Response.End();

注意点:open方法指定get还是post,同步还是异步,异步回调方法的指定和参数传递

       后台的Response.End(),否则会把所有网页都返回

posted on 2010-04-01 17:47  优雅小猪  阅读(318)  评论()    收藏  举报