my requirement is : when user clicks on a button until the data is fetched, display a text "Searching...". I am using a JSON function to fetch data. But the problem is I am able to display the "Searching ..." text on button click only in Firefox, not in chrome or IE. I have tried beforeSend also, but even tat works only in Firefox. I have read that async =false, is causing this issue, but i need synchronous call only for this.
我的要求是:当用户单击一个按钮,直到获取数据时,显示一个文本“搜索…”。我正在使用JSON函数来获取数据。但问题是我只能在Firefox中显示“搜索……”文本,而不是在chrome或IE中。我也试过了,但即使是只在Firefox中使用。我已经读过async =false导致了这个问题,但是我只需要同步调用。
<span id="searchWait" > </span>
<script>
function getPromptSearchResults() {
$('#searchWait').html('Searching...');
$.ajax({
async: false,
url: 'Application.aspx/getPromptSearchResults',
data: JSON.stringify({
some parameters
}),
success: function (data) {
$('#searchWait').html('');
something
},
error: function (parameters) {
something
}
});
return something;
}
</script>
1 个解决方案
#1
0
You need to call $('#searchWait').show();
so that it changes the style attribute and is no longer hidden.
您需要调用$('#searchWait').show();这样它就改变了style属性,不再被隐藏。
Check out this fiddle: http://jsfiddle.net/ambiguous/zLnED/
看看这个小提琴:http://jsfiddle.net/ous/zlned/
That isn't my fiddle, but I would recommend changing the timeout to 100-500 for more reliability.
这不是我的问题,但我建议将超时时间改为100-500,以获得更高的可靠性。
#1
0
You need to call $('#searchWait').show();
so that it changes the style attribute and is no longer hidden.
您需要调用$('#searchWait').show();这样它就改变了style属性,不再被隐藏。
Check out this fiddle: http://jsfiddle.net/ambiguous/zLnED/
看看这个小提琴:http://jsfiddle.net/ous/zlned/
That isn't my fiddle, but I would recommend changing the timeout to 100-500 for more reliability.
这不是我的问题,但我建议将超时时间改为100-500,以获得更高的可靠性。