Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/76.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 jquery对话框暂停类似alert()的脚本_Javascript_Jquery - Fatal编程技术网

Javascript jquery对话框暂停类似alert()的脚本

Javascript jquery对话框暂停类似alert()的脚本,javascript,jquery,Javascript,Jquery,我有下一个javascript代码: function getLetterOfResponsibilityNote(dialogNoteLink, visitCountryName) { $.ajax({ type: "GET", url: "/Admin/Applications/GetLetterOfResponsibilityNote/?selectedCountryName=" + visitCountryName,

我有下一个javascript代码:

function getLetterOfResponsibilityNote(dialogNoteLink, visitCountryName) {
        $.ajax({
            type: "GET",
            url: "/Admin/Applications/GetLetterOfResponsibilityNote/?selectedCountryName=" + visitCountryName,
            cache: false,
            success: function(data) {
                if (data != "") {
                    dialogNoteLink.dialog();
                    dialogNoteLink.attr("title", "Letter Of Responsibility Note for " + visitCountryName);
                    dialogNoteLink.html("<p>" + data + "</p>");
                }
            }
        });
    }
函数getLetterOfResponsibilityNote(dialogNoteLink,VisitCountyName){ $.ajax({ 键入:“获取”, url:“/Admin/Applications/GetLetterOfResponsibilityNote/?selectedCountryName=“+visitCountryName, cache:false, 成功:功能(数据){ 如果(数据!=“”){ dialogNoteLink.dialog(); dialogNoteLink.attr(“标题”,“责任书”+visitCountyname); dialogNoteLink.html(“”+data+“

”); } } }); } 我想调用它,例如,5次并从服务器获取数据,然后我将在对话框中显示它。但我得到一个带有消息的jQueryUI对话框。问题是当对话框打开时脚本不会暂停

如果我不写,而是写:

dialogNoteLink.dialog();
dialogNoteLink.attr("title", "Letter Of Responsibility Note for " + visitCountryName);
dialogNoteLink.html("<p>" + data + "</p>");
dialogNoteLink.dialog();
dialogNoteLink.attr(“标题”,“责任书”+visitCountyname);
dialogNoteLink.html(“”+data+“

”);
使用alert()-工作正常


如何解决此问题?

该对话框应显示在对服务器的查询回调中


JQuery上没有阻塞函数或对话框。

这就是JavaScript警报的工作方式。如果要使调用等待对话框关闭,则必须在对话框关闭后在回调中进行后续调用。你应该这样做-

var arrayofNotesAndCountryNames = [{
 "dialogNoteLink" : link1,
 "visitCountryName" : "country1"
},{
 "dialogNoteLink" : link2,
 "visitCountryName" : "country2"
},{
 "dialogNoteLink" : link3,
 "visitCountryName" : "country3"
}];    
var currentIndex = 0;

function getLetterOfResponsibilityNote() {
var dialogNoteLink = arrayofNotesAndCountryNames[currentIndex].dialogNoteLink;
var visitCountryName = arrayofNotesAndCountryNames[currentIndex].visitCountryName;
            $.ajax({
                type: "GET",
                url: "/Admin/Applications/GetLetterOfResponsibilityNote/?selectedCountryName=" + visitCountryName,
                cache: false,
                success: function(data) {
                    if (data != "") {
                        dialogNoteLink.dialog({close : function(){ 
                             currentIndex++;
                             if (currentIndex < arrayofNotesAndCountryNames.length){
                                  getLetterOfResponsibilityNote();
                             }

                        }

});
                        dialogNoteLink.attr("title", "Letter Of Responsibility Note for " + visitCountryName);
                        dialogNoteLink.html("<p>" + data + "</p>");
                    }
                }
            });
        }

getLetterOfResponsibilityNote();
var arrayofNotesAndCountryNames=[{
“dialogNoteLink”:链接1,
“visitCountryName”:“country1”
},{
“dialogNoteLink”:链接2,
“VisitCountyName”:“country2”
},{
“dialogNoteLink”:链接3,
“VisitCountyName”:“country3”
}];    
var currentIndex=0;
函数getLetterOfResponsibilityNote(){
var dialogNoteLink=arrayofNotesAndCountryNames[currentIndex]。dialogNoteLink;
var visitCountryName=arrayofNotesAndCountryNames[currentIndex]。visitCountryName;
$.ajax({
键入:“获取”,
url:“/Admin/Applications/GetLetterOfResponsibilityNote/?selectedCountryName=“+visitCountryName,
cache:false,
成功:功能(数据){
如果(数据!=“”){
dialogNoteLink.dialog({close:function(){
currentIndex++;
如果(currentIndex”);
}
}
});
}
getLetterOfResponsibilityNote();