AJAX样式处理图标 [英] AJAX Style processing icon

查看:73
本文介绍了AJAX样式处理图标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用AJAX风格处理图标。

进程我在后台运行xmlHttp是密集的,

需要5-10秒才能完成。而不是我的处理图标

出现在页面中,页面在此过程中冻结,直到

它已经完成。这是显示此类图标的最佳方式吗?

我能做什么才能正常使用?谢谢


函数stateChanged()

{

if(xmlHttp.readyState == 0)

{

document.getElementById(" lblResults")。innerHTML ="< img

src =''mozilla_blu.gif''alt =''loading。 .please wait''>" ;; // loading

}

else if(xmlHttp.readyState == 1)

{

document.getElementById (< lblResults")。innerHTML ="< img

src =''mozilla_blu.gif''alt =''loading..please wait''>" ;; // loading

}

else if(xmlHttp.readyState == 2)

{

document.getElementById (< lblResults")。innerHTML ="< img

src =''mozilla_blu.gif''alt =''loading..please wait''>" ;; //互动

}

else if(xmlHttp.readyState == 3)

{

document.getElementById (< lblResults")。innerHTML ="< img

src =''mozilla_blu.gif''alt =''loading..please wait''>" ;;

}

else if(xmlHttp.readyState == 4 || xmlHttp.readyState ==" complete")

{

document.getElementById(" lblResults")。innerHTML ="" ;;

< span id =" lblResults" name =" lblResults">< / span>

I''m experimenting with using a AJAX style "processing" icon. The
process I''m running in the background with xmlHttp is intensive and
takes a 5--10 secs to complete. Instead of my processing icon
appearing in the page, the page just freezes during the process until
it''s finished. Is this the best way to display this kind of icon?
What can I do so this works right? Thanks

function stateChanged()
{
if (xmlHttp.readyState == 0)
{
document.getElementById("lblResults").innerHTML = "<img
src=''mozilla_blu.gif'' alt=''loading..please wait''>"; //loading
}
else if(xmlHttp.readyState == 1)
{
document.getElementById("lblResults").innerHTML = "<img
src=''mozilla_blu.gif'' alt=''loading..please wait''>"; //loaded
}
else if(xmlHttp.readyState == 2)
{
document.getElementById("lblResults").innerHTML = "<img
src=''mozilla_blu.gif'' alt=''loading..please wait''>"; //interactive
}
else if(xmlHttp.readyState == 3)
{
document.getElementById("lblResults").innerHTML = "<img
src=''mozilla_blu.gif'' alt=''loading..please wait''>";
}
else if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{
document.getElementById("lblResults").innerHTML = "";
<span id="lblResults" name="lblResults"></span>

推荐答案

4月13日下午1:28,shankwheat ; < evanbu ... @ gmail.comwrote:
On Apr 13, 1:28 pm, "shankwheat" <evanbu...@gmail.comwrote:

我正在尝试使用AJAX风格处理图标。

进程我在后台运行xmlHttp是密集的,

需要5-10秒才能完成。而不是我的处理图标

出现在页面中,页面在此过程中冻结,直到

它已经完成。这是显示此类图标的最佳方式吗?

我能做什么才能正常使用?谢谢


函数stateChanged()

{

if(xmlHttp.readyState == 0)

{

document.getElementById(" lblResults")。innerHTML ="< img

src =''mozilla_blu.gif''alt =''loading。 .please wait''>" ;; // loading

}

else if(xmlHttp.readyState == 1)

{

document.getElementById (< lblResults")。innerHTML ="< img

src =''mozilla_blu.gif''alt =''loading..please wait''>" ;; // loading

}

else if(xmlHttp.readyState == 2)

{

document.getElementById (< lblResults")。innerHTML ="< img

src =''mozilla_blu.gif''alt =''loading..please wait''>" ;; //互动

}

else if(xmlHttp.readyState == 3)

{

document.getElementById (< lblResults")。innerHTML ="< img

src =''mozilla_blu.gif''alt =''loading..please wait''>" ;;

}

else if(xmlHttp.readyState == 4 || xmlHttp.readyState ==" complete")

{

document.getElementById(" lblResults")。innerHTML ="" ;;


< span id =" lblResults"名称= QUOT; lblResults">< /跨度>
I''m experimenting with using a AJAX style "processing" icon. The
process I''m running in the background with xmlHttp is intensive and
takes a 5--10 secs to complete. Instead of my processing icon
appearing in the page, the page just freezes during the process until
it''s finished. Is this the best way to display this kind of icon?
What can I do so this works right? Thanks

function stateChanged()
{
if (xmlHttp.readyState == 0)
{
document.getElementById("lblResults").innerHTML = "<img
src=''mozilla_blu.gif'' alt=''loading..please wait''>"; //loading
}
else if(xmlHttp.readyState == 1)
{
document.getElementById("lblResults").innerHTML = "<img
src=''mozilla_blu.gif'' alt=''loading..please wait''>"; //loaded
}
else if(xmlHttp.readyState == 2)
{
document.getElementById("lblResults").innerHTML = "<img
src=''mozilla_blu.gif'' alt=''loading..please wait''>"; //interactive
}
else if(xmlHttp.readyState == 3)
{
document.getElementById("lblResults").innerHTML = "<img
src=''mozilla_blu.gif'' alt=''loading..please wait''>";
}
else if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{
document.getElementById("lblResults").innerHTML = "";

<span id="lblResults" name="lblResults"></span>



您可以将代码发布到您打开的地方并发送

XmlHTTPRequest吗?

Can you post the code where you are opening and sending the
XmlHTTPRequest?


4月13日下午1:46,Jason < redundancy ... @ gmail.comwrote:
On Apr 13, 1:46 pm, "Jason" <redund...@gmail.comwrote:

4月13日下午1:28,shankwheat < evanbu ... @ gmail.comwrote:

On Apr 13, 1:28 pm, "shankwheat" <evanbu...@gmail.comwrote:



我正在尝试使用AJAX风格处理图标。

进程我在后台运行xmlHttp是密集的,

需要5-10秒才能完成。而不是我的处理图标

出现在页面中,页面在此过程中冻结,直到

它已经完成。这是显示此类图标的最佳方式吗?

我能做什么才能正常使用?谢谢
I''m experimenting with using a AJAX style "processing" icon. The
process I''m running in the background with xmlHttp is intensive and
takes a 5--10 secs to complete. Instead of my processing icon
appearing in the page, the page just freezes during the process until
it''s finished. Is this the best way to display this kind of icon?
What can I do so this works right? Thanks


函数stateChanged()

{

if(xmlHttp.readyState == 0 )

{

document.getElementById(" lblResults")。innerHTML ="< img

src =''mozilla_blu.gif ''alt =''loading..please wait''>" ;; // loading

}

else if(xmlHttp.readyState == 1)

{

document.getElementById (< lblResults")。innerHTML ="< img

src =''mozilla_blu.gif''alt =''loading..please wait''>" ;; // loading

}

else if(xmlHttp.readyState == 2)

{

document.getElementById (< lblResults")。innerHTML ="< img

src =''mozilla_blu.gif''alt =''loading..please wait''>" ;; //互动

}

else if(xmlHttp.readyState == 3)

{

document.getElementById (< lblResults")。innerHTML ="< img

src =''mozilla_blu.gif''alt =''loading..please wait''>" ;;

}

else if(xmlHttp.readyState == 4 || xmlHttp.readyState ==" complete")

{

document.getElementById(" lblResults")。innerHTML ="" ;;
function stateChanged()
{
if (xmlHttp.readyState == 0)
{
document.getElementById("lblResults").innerHTML = "<img
src=''mozilla_blu.gif'' alt=''loading..please wait''>"; //loading
}
else if(xmlHttp.readyState == 1)
{
document.getElementById("lblResults").innerHTML = "<img
src=''mozilla_blu.gif'' alt=''loading..please wait''>"; //loaded
}
else if(xmlHttp.readyState == 2)
{
document.getElementById("lblResults").innerHTML = "<img
src=''mozilla_blu.gif'' alt=''loading..please wait''>"; //interactive
}
else if(xmlHttp.readyState == 3)
{
document.getElementById("lblResults").innerHTML = "<img
src=''mozilla_blu.gif'' alt=''loading..please wait''>";
}
else if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{
document.getElementById("lblResults").innerHTML = "";


< span id =" lblResults"名称= QUOT; lblResults">< /跨度>
<span id="lblResults" name="lblResults"></span>



你可以在你打开的地方发布代码并发送

XmlHTTPRequest吗? - 隐藏引用的文字 -

- 显示引用的文字 -


Can you post the code where you are opening and sending the
XmlHTTPRequest?- Hide quoted text -

- Show quoted text -



这就是我正在使用的。谢谢


函数getIndustries()

{

xmlHttp = GetXmlHttpObject()

if(xmlHttp == null)

{

alert("您的浏览器不支持XMLHttpRequest对象。)

返回

}

var url =" getIndustries.aspx"

xmlHttp.onreadystatechange = stateChanged

xmlHttp.open(" GET" ;,url,true)

xmlHttp.send(null)

}


函数stateChanged()

{

if(xmlHttp.readyState == 0)

{

document.getElementById(" lblResults")。innerHTML = "< img

src =''mozilla_blu.gif''alt =''loading..please wait''>" ;; // loading

}

else if(xmlHttp.readyState == 1)

{

document.getElementById (< lblResults")。innerHTML ="< img

src =''mozilla_blu.gif''alt =''loading..please wait''>" ;; // loading

}

else if(xmlHttp.readyState == 2)

{

document.getElementById (< lblResults")。innerHTML ="< img

src =''mozilla_blu.gif''alt =''loading..please wait''>" ;; //互动

}

else if(xmlHttp.readyState == 3)

{

document.getElementById (< lblResults")。innerHTML ="< img

src =''mozilla_blu.gif''alt =''loading..please wait''>" ;;

}

else if(xmlHttp.readyState == 4 || xmlHttp.readyState ==" complete")

{

document.getElementById(" lblResults")。innerHTML ="" ;;


//清除以前任何选项的可用列表框

document .choiceForm.available.length = 0;


//将分隔的响应拆分为数组

results = xmlHttp.responseText.split("," ;);


for(var i = 0; i< results.length; ++ i){

addOption(document.choiceForm.available,结果[i],结果[i]);

}

}

}


function addOption(selectbox,text,value)

{

var optn = document.createEl ement(" OPTION&qu​​ot;);

optn.text = text;

optn.value = value;

selectbox.options.add( optn);

}

This is what I''m using. Thanks

function getIndustries()
{
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
{
alert ("Your browser does not support the XMLHttpRequest object.")
return
}
var url="getIndustries.aspx"
xmlHttp.onreadystatechange=stateChanged
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}

function stateChanged()
{
if (xmlHttp.readyState == 0)
{
document.getElementById("lblResults").innerHTML = "<img
src=''mozilla_blu.gif'' alt=''loading..please wait''>"; //loading
}
else if(xmlHttp.readyState == 1)
{
document.getElementById("lblResults").innerHTML = "<img
src=''mozilla_blu.gif'' alt=''loading..please wait''>"; //loaded
}
else if(xmlHttp.readyState == 2)
{
document.getElementById("lblResults").innerHTML = "<img
src=''mozilla_blu.gif'' alt=''loading..please wait''>"; //interactive
}
else if(xmlHttp.readyState == 3)
{
document.getElementById("lblResults").innerHTML = "<img
src=''mozilla_blu.gif'' alt=''loading..please wait''>";
}
else if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{
document.getElementById("lblResults").innerHTML = "";

// Clear the available listbox of any previous options
document.choiceForm.available.length = 0;

// Split the delimited response into an array
results = xmlHttp.responseText.split(",");

for (var i=0; i < results.length;++i){
addOption(document.choiceForm.available, results[i], results[i]);
}
}
}

function addOption(selectbox,text,value )
{
var optn = document.createElement("OPTION");
optn.text = text;
optn.value = value;
selectbox.options.add(optn);
}


4月13日下午2:18,shankwheat < evanbu ... @ gmail.comwrote:
On Apr 13, 2:18 pm, "shankwheat" <evanbu...@gmail.comwrote:

4月13日下午1:46,Jason < redundancy ... @ gmail.comwrote:
On Apr 13, 1:46 pm, "Jason" <redund...@gmail.comwrote:

4月13日下午1:28,shankwheat < evanbu ... @ gmail.comwrote:
On Apr 13, 1:28 pm, "shankwheat" <evanbu...@gmail.comwrote:


我正在尝试使用AJAX风格 ;处理"图标。

进程我在后台运行xmlHttp是密集的,

需要5-10秒才能完成。而不是我的处理图标

出现在页面中,页面在此过程中冻结,直到

它已经完成。这是显示此类图标的最佳方式吗?

我能做什么才能正常使用?谢谢
I''m experimenting with using a AJAX style "processing" icon. The
process I''m running in the background with xmlHttp is intensive and
takes a 5--10 secs to complete. Instead of my processing icon
appearing in the page, the page just freezes during the process until
it''s finished. Is this the best way to display this kind of icon?
What can I do so this works right? Thanks


function stateChanged()

{

if(xmlHttp.readyState == 0)

{

document.getElementById(" lblResults")。innerHTML ="< img

src =''mozilla_blu.gif''alt =''loading..please wait''>" ;; // loading

}

else if(xmlHttp.readyState == 1)

{

document.getElementById (< lblResults")。innerHTML ="< img

src =''mozilla_blu.gif''alt =''loading..please wait''>" ;; // loading

}

else if(xmlHttp.readyState == 2)

{

document.getElementById (< lblResults")。innerHTML ="< img

src =''mozilla_blu.gif''alt =''loading..please wait''>" ;; //互动

}

else if(xmlHttp.readyState == 3)

{

document.getElementById (< lblResults")。innerHTML ="< img

src =''mozilla_blu.gif''alt =''loading..please wait''>" ;;

}

else if(xmlHttp.readyState == 4 || xmlHttp.readyState ==" complete")

{

document.getElementById(" lblResults")。innerHTML ="" ;;
function stateChanged()
{
if (xmlHttp.readyState == 0)
{
document.getElementById("lblResults").innerHTML = "<img
src=''mozilla_blu.gif'' alt=''loading..please wait''>"; //loading
}
else if(xmlHttp.readyState == 1)
{
document.getElementById("lblResults").innerHTML = "<img
src=''mozilla_blu.gif'' alt=''loading..please wait''>"; //loaded
}
else if(xmlHttp.readyState == 2)
{
document.getElementById("lblResults").innerHTML = "<img
src=''mozilla_blu.gif'' alt=''loading..please wait''>"; //interactive
}
else if(xmlHttp.readyState == 3)
{
document.getElementById("lblResults").innerHTML = "<img
src=''mozilla_blu.gif'' alt=''loading..please wait''>";
}
else if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{
document.getElementById("lblResults").innerHTML = "";


< span id =" lblResults"名称= QUOT; lblResults">< /跨度>
<span id="lblResults" name="lblResults"></span>


你能发布你打开的代码并发送

XmlHTTPRequest吗? - 隐藏引用的文字 -
Can you post the code where you are opening and sending the
XmlHTTPRequest?- Hide quoted text -


- 显示引用的文字 -
- Show quoted text -



这就是我正在使用的。谢谢


函数getIndustries()

{

xmlHttp = GetXmlHttpObject()

if(xmlHttp == null)

{

alert("您的浏览器不支持XMLHttpRequest对象。)

返回


}


var url =" getIndustries.aspx"

xmlHttp.onreadystatechange = stateChanged

xmlHttp.open(" GET",url,true)

xmlHttp.send(null)


}


函数stateChanged()

{

if(xmlHttp.readyState == 0)

{

document.getElementById(" lblResults")。innerHTML ="< img

src =''mozilla_blu.gif''alt =''loading..please wait''>" ;; // loading

}

else if(xmlHttp.readyState == 1)

{

document.getElementById (< lblResults")。innerHTML ="< img

src =''mozilla_blu.gif''alt =''loading..please wait''>" ;; // loading

}

else if(xmlHttp.readyState == 2)

{

document.getElementById (< lblResults")。innerHTML ="< img

src =''mozilla_blu.gif''alt =''loading..please wait''>" ;; //互动

}

else if(xmlHttp.readyState == 3)

{

document.getElementById (< lblResults")。innerHTML ="< img

src =''mozilla_blu.gif''alt =''loading..please wait''>" ;;

}

else if(xmlHttp.readyState == 4 || xmlHttp.readyState ==" complete")

{

document.getElementById(" lblResults")。innerHTML ="" ;;


//清除以前任何选项的可用列表框

document .choiceForm.available.length = 0;


//将分隔的响应拆分为数组

results = xmlHttp.responseText.split("," ;);


for(var i = 0; i< results.length; ++ i){

addOption(document.choiceForm.available,结果[i],结果[i]);


}

}

}


函数addOption(选择框,文本,值)

{

var optn = document.createElement(" OPTION&qu​​ot;);

optn.text = text;

optn.value = value;

selectbox.options.add(optn);


}


This is what I''m using. Thanks

function getIndustries()
{
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
{
alert ("Your browser does not support the XMLHttpRequest object.")
return

}

var url="getIndustries.aspx"
xmlHttp.onreadystatechange=stateChanged
xmlHttp.open("GET",url,true)
xmlHttp.send(null)

}

function stateChanged()
{
if (xmlHttp.readyState == 0)
{
document.getElementById("lblResults").innerHTML = "<img
src=''mozilla_blu.gif'' alt=''loading..please wait''>"; //loading
}
else if(xmlHttp.readyState == 1)
{
document.getElementById("lblResults").innerHTML = "<img
src=''mozilla_blu.gif'' alt=''loading..please wait''>"; //loaded
}
else if(xmlHttp.readyState == 2)
{
document.getElementById("lblResults").innerHTML = "<img
src=''mozilla_blu.gif'' alt=''loading..please wait''>"; //interactive
}
else if(xmlHttp.readyState == 3)
{
document.getElementById("lblResults").innerHTML = "<img
src=''mozilla_blu.gif'' alt=''loading..please wait''>";
}
else if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{
document.getElementById("lblResults").innerHTML = "";

// Clear the available listbox of any previous options
document.choiceForm.available.length = 0;

// Split the delimited response into an array
results = xmlHttp.responseText.split(",");

for (var i=0; i < results.length;++i){
addOption(document.choiceForm.available, results[i], results[i]);

}
}
}

function addOption(selectbox,text,value )
{
var optn = document.createElement("OPTION");
optn.text = text;
optn.value = value;
selectbox.options.add(optn);

}



只是一个观察,你为什么不设置lblResults的innerHTML

发送请求后立即检查readyState ==

4.


var url = " getIndustries.aspx"

xmlHttp.onreadystatechange = stateChanged

xmlHttp.open(" GET",url,true)

xmlHttp。 send(null)

document.getElementById(" lblResults")。innerHTML ="< img

src =''mozilla_blu.gif''alt ='' loading..please wait''>" ;; // loading

}


函数stateChanged()

{

if(xmlHttp.readyState == 4){

//做东西

}

}


它会使减少了浏览器的工作量。

Just an observation, why don''t you set the innerHTML of lblResults
right after you send the request and then just check for readyState ==
4.

var url="getIndustries.aspx"
xmlHttp.onreadystatechange=stateChanged
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
document.getElementById("lblResults").innerHTML = "<img
src=''mozilla_blu.gif'' alt=''loading..please wait''>"; //loading
}

function stateChanged()
{
if(xmlHttp.readyState == 4) {
//do stuff
}
}

It will make less work for the browser.


这篇关于AJAX样式处理图标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆