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. 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. When it returns true
, the other dialog appears correctly.
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. 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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.