在$。当呼叫进程 [英] progress on $.when call

查看:103
本文介绍了在$。当呼叫进程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图做一些AJAX调用使用 $。当 $。然后功能。 我使用这些功能来一补模板等,在此同时,我要补,我将用一些消息填补像

I am trying to do some AJAX call using $.when and $.then functions. I am using these functions to fill a template and so , in the meanwhile , I want to fill the form that I will fill with some message like

加载数据..请稍候

我发现有一个进度的功能,但它仅适用于通知。我搜索通过社区,我注意到,它是用来与通话。我并没有真正得到的,以及如何延期对象都工作在我的剧本的意思。

I found out that there is a progress functions but it works only with notify. I searched through the community and I noticed that it is used with the promise call. I did not really get the meaning of promise and how deferred objects are working in my script.

这是我的脚本:

         $.when(e.get_info('get_utente'))
            }).then(function(data){
                 $('#username').val(data.username);
                 $('#email').val(data.email);
         })

我想插入进步beetween这两个电话。 很抱歉,如果有一些误解,但到现在我是用异步:假,之后我发现这是一个非常糟糕的主意,我发现了延期的对象,但我dindn吨得到所有它的逻辑

I would like to insert progress beetween this two calls. Sorry if there's some misunderstanding , but 'till now I was using ASYNC : false , and after i noticed that is a really bad idea I found out deferred objects , but i dindn't get at all it's logic

推荐答案

进度回调并不真正适用于在这个时候Ajax请求。

The progress callback doesn't really apply to ajax requests at this time.

相反,做你的加载数据..请稍候之前 $消息。当

Instead, do your "loading data.. please wait" message before $.when.

另外,你不需要 $。当可言,只是做

Also, you don't need $.when at all, just do

$("#loading").show();
e.get_info('get_utente').done(function(data){
    $("#loading").hide();
    $('#username').val(data.username);
    $('#email').val(data.email);
});

$。当如果你需要运行一些东西时,2个或更多的承诺对象是完整的,才需要。对于单一的承诺对象时,它是不需要的。

$.when is only needed if you need to run something when 2 or more promise objects are complete. For a single promise object, it is not needed.

这篇关于在$。当呼叫进程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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