Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/wix/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 在函数执行后继续ajax处理_Javascript_Jquery_Ajax - Fatal编程技术网

Javascript 在函数执行后继续ajax处理

Javascript 在函数执行后继续ajax处理,javascript,jquery,ajax,Javascript,Jquery,Ajax,我有一种情况,我需要执行一个函数,但警报阻止函数执行,即使在调用之后。所以我需要在确认()之前执行llamadaEntrante();但是不能让它工作,有什么想法吗 代码如下: $.ajax({ type: "GET", data: {func: 'checkLlamadaEntrante'}, url: 'https://www.cge.mil.ar/adm_sis/pedirLlamada.aspx' }) .done(function (data) { if

我有一种情况,我需要执行一个函数,但警报阻止函数执行,即使在调用之后。所以我需要在确认()之前执行
llamadaEntrante()
;但是不能让它工作,有什么想法吗

代码如下:

$.ajax({
    type: "GET",
    data: {func: 'checkLlamadaEntrante'},
    url: 'https://www.cge.mil.ar/adm_sis/pedirLlamada.aspx'
})
.done(function (data) {
    if (data != 0){
        llamadaEntrante();
        var array = data.split(',');
        conf_id = array[1];
        enEsperaDeConfirmacion(conf_id);
        var r = confirm("Tiene una llamada de "+array[0]);
        if (r == true) {
            aceptaLlamada(conf_id);
            $("#videoLlamada_container").children('iframe').remove();
            $("#videoLlamada_container").show('slow');
            $("#videoLlamada_container").children('div.buscardor_grilla').children('input:first').focus();
            $("#videoLlamada_container").append('<iframe src="https://www.cge.mil.ar/videollamadaapp/default.aspx?conf_id='+conf_id+'" height="410px" width="534px" scroll="no"></iframe>');
            $("#option_aux").hide();
        } else {
            cancelaLlamada(conf_id);
        }
        cortaEntrante();
    } else {
        console.info('no llamaron');
    }

});
$.ajax({
键入:“获取”,
数据:{func:'checkLlamadaEntrante'},
网址:'https://www.cge.mil.ar/adm_sis/pedirLlamada.aspx'
})
.完成(功能(数据){
如果(数据!=0){
llamadaEntrante();
var数组=data.split(',');
conf_id=array[1];
e勘探确认(conf_id);
var r=确认(“Tiene una llamada de”+数组[0]);
如果(r==true){
Aceptalamada(身份证);
$(“#videoLlamada_容器”).children('iframe').remove();
$(“#videoLlamada_容器”).show('slow');
$(“#videoLlamada_container”).children('div.buscardor_grilla').children('input:first').focus();
$(“#videoLlamada_容器”)。附加(“”);
$(“#选项_aux”).hide();
}否则{
cancelaLlamada(conf_id);
}
cortaEntrante();
}否则{
console.info(“无llamaron”);
}
});

我想这应该行得通。。。你知道承诺吗

function llamadaEntrante()
{
    return new Promise(function(resolve, reject){

        // put your normal llamadaEntrante code in here
        // doing some stuff
        // and then resolve the promise with just true in this case
        resolve(true);

    });
}
所以我想澄清一下

$.ajax({
        type: "GET",
        data: {func: 'checkLlamadaEntrante'},
        url: 'https://www.cge.mil.ar/adm_sis/pedirLlamada.aspx'
    })
    .done(function (data) {
        if (data != 0)
        {
            llamadaEntrante()
            .then(function()
            {
                var array = data.split(',');
                conf_id = array[1];
                enEsperaDeConfirmacion(conf_id);

                var r = confirm("Tiene una llamada de "+array[0]);
                if (r == true) 
                {
                    aceptaLlamada(conf_id);
                    $("#videoLlamada_container").children('iframe').remove();
                    $("#videoLlamada_container").show('slow');
                    $("#videoLlamada_container").children('div.buscardor_grilla').children('input:first').focus();
                    $("#videoLlamada_container").append('<iframe src="https://www.cge.mil.ar/videollamadaapp/default.aspx?conf_id='+conf_id+'" height="410px" width="534px" scroll="no"></iframe>');
                    $("#option_aux").hide();
                } else 
                    cancelaLlamada(conf_id);

                cortaEntrante();

            });
        }else{
            console.info('no llamaron');
        }
    });
$.ajax({
键入:“获取”,
数据:{func:'checkLlamadaEntrante'},
网址:'https://www.cge.mil.ar/adm_sis/pedirLlamada.aspx'
})
.完成(功能(数据){
如果(数据!=0)
{
llamadaEntrante()
.然后(函数()
{
var数组=data.split(',');
conf_id=array[1];
e勘探确认(conf_id);
var r=确认(“Tiene una llamada de”+数组[0]);
如果(r==true)
{
Aceptalamada(身份证);
$(“#videoLlamada_容器”).children('iframe').remove();
$(“#videoLlamada_容器”).show('slow');
$(“#videoLlamada_container”).children('div.buscardor_grilla').children('input:first').focus();
$(“#videoLlamada_容器”)。附加(“”);
$(“#选项_aux”).hide();
}否则
cancelaLlamada(conf_id);
cortaEntrante();
});
}否则{
console.info(“无llamaron”);
}
});

除非LLAMADAENTRATE()已完成,否则无法到达“确认”(“Tiene una llamada de”+array[0]);”,这毫无意义。“first confirm()”是什么意思?不管是谁做的,你能解释一下吗?这是对“所问问题”的完全合理的回答!但我不会点击投票否决:S。。confirm()在promise之前调用,不知道为什么会这样。。无论如何,我已经创建了一个类似于模态的“确认”,所以我创建了一个dinamic框来确认和工作。。至少我可以做我想做的事=)。