English 中文(简体)
在JQuery调用JSJS 函数(和通过辩论)ASYNC
原标题:Call JS Function (and pass arguments) ASYNC in JQuery

我有以下代码 用来获取 xml 文件, 并转换成 JSON :

showLoading();
$.get(data_file_path, {}, function(content, textStatus, jqXHR){
        data_object = jqXHR;
        jsonObject = xml2json.parser(data_object.responseText);         
        hideLoading();
    });

数据_ file_ path is a. xml 文件。 使用此当前代码, 装入. gif 不旋转, 因为 xml2json. parser () 调用没有进行非同步 。 这只是 JavaScript 函数。 仅此而已。 仅此而已。 如何调用 ALSO Async, 使加载. gif 保持旋转, 然后在 jsonObject 解析时通常隐藏?

问题回答

AJAX之所以站不住脚, 是因为在从服务器获取数据时, 你不必不断运行代码, 脚本可以说“好了, 完成之后, 做这个 ” 。

然而, xml2json.parser 是一个 JS 脚本。 它一直运行代码直到完成, 因此无法重写 。

唯一的办法就是手动编程 你自己的版本 这样它就能在计时器上 逐个地装上一个计时器





相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签