函数执行后继续ajax处理
Continue ajax processing after function execute
我有一种情况,我需要执行一个函数,但警报阻止函数执行,即使它在调用之后。所以我需要llamadaEntrante()
在confirm()
之前执行;但却行不通,有什么想法吗?
代码如下:
$.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');
}
});
我想这应该行得通…你知道什么是承诺吗?
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处理的保存操作
- 我应该如何使用Ajax处理验证错误
- 如何使用AJAX处理从PHP脚本返回的数组
- 一个 ajax 处理程序或多个处理程序
- 单线程 Javascript 和 AJAX 处理
- 将数组传递给 jQuery 以进行 AJAX 处理
- 无法检索 AJAX 处理的内容
- 在 IE 8 中使用 AJAX 处理http_request
- 尝试使用Fancybox / Ajax处理登录错误
- 在 POST ajax 处理程序中更改 window.location 会发出新的 ajax 调用,而不是重定向
- 如何在wordpress中制作自定义ajax处理程序
- 如何在javascript中使用ajax处理历史
- 根据泛型函数中的参数动态添加ajax处理程序
- Ajax处理页面加载,但不处理按钮单击
- 使用jQuery Deferred链接AJAX处理程序
- jQuery-设置Ajax处理程序优先级
- 未调用AJAX处理程序(不确定是PHP还是JavaScript问题)
- 函数执行后继续ajax处理
- 在AJAX处理页面上调用php变量
- Ajax.处理两个不同的onSuccess响应,MVC 5, c#