简体   繁体   English

jQuery对话框未显示

[英]jQuery Dialog not showing

It seems like one of my two dialog box won't show up, although the second one does when asked to. 似乎我的两个对话框之一不会出现,尽管第二个对话框在出现要求时会出现。 Both are inside a $.get() success function. 两者都在$.get()成功函数内。 It is as shown: 如图所示:

$.getJSON('addCategory.php', {'ordre':ordre,'nom':nom}, function(data) 
                            {
                                console.log(data.result);

                                    $('div id="Dialog_Feedback2">Une catégorie porte déjà ce nom ou cet ordre!</div>').dialog(
                                    {
                                        autoOpen:false,
                                        title:'Une erreur est survenue!',
                                        width:300,
                                        height:'auto',
                                        resizable: false,
                                        show:"slide",
                                        modal:true,
                                        buttons:{
                                            "OK" : function()
                                            {
                                                $( this ).remove();
                                            }
                                        }
                                    });

                                    $('<div id="Dialog_Feedback">L\'ajout a été effectué avec succès!</div>').dialog({
                                        autoOpen:false,
                                        title:'Catégorie ajoutée!',
                                        width:400,
                                        height:'auto',
                                        resizable:false,
                                        modal:true,
                                        buttons:{
                                            "Ok": function()
                                            {
                                                $(this).remove();
                                                window.location.reload();
                                            }
                                        }
                                    }); 
                                    if(data.result =="true")
                                    {
                                        console.log("NO!");
                                        $('#Dialog_Feedback').dialog("open");
                                    }
                                    else
                                    {
                                        console.log("Yeah!");
                                        $('#Dialog_Feedback2').dialog("open");

                                    }                           
                                }

                            );
                        }

Here is what I see in the console: 这是我在控制台中看到的内容:

false

Yeah!

But the #Dialog_Feedback2 won't show up. 但是#Dialog_Feedback2将不会显示。 When it returns true , the other dialog appears correctly. 当它返回true ,另一个对话框将正确显示。

Why won't the second dialog show up? 为什么第二个对话框不显示?

It's a very simple problem, all you have to do is correctly write the div tag, you are missing the beginning carat. 这是一个非常简单的问题,您所要做的就是正确编写div标签,而您缺少开始的克拉。 So the line 所以线

$('div id="Dialog_Feedback2">Une catégorie porte déjà ce nom ou cet ordre</div>').dialog(`

Should begin with 应该以

$('<d

not just 不只是

$('d

This should give you your desired operation. 这将为您提供所需的操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM