Why is this Ajax conditional dialog not working? <p>Why is this code not working?</p> <p>In the meantime (trying to make it work) i have changed it a dosen time, but i can't find the solution.</p> <p>Anyone has an idea? I have no errors in console.</p> <p>First of all, it check's if a dialog needs to be opened.</p> <p>This is the workflow:</p> <p>If DialogRequired => Dialog.Click = OK --> execute an ajax call If DialogRequired => Dialog.Click = Cancel --> do nothing If Dialog NOT Required => execute an ajax call</p> <pre><code>$(function () { $("a.orderlink").unbind(); $("a.orderlink").bind("click", function () { var ProductID = $(this).parent().attr("data-productid"); var Ammount = $(this).parent().parent().find("input#ammount").val(); $.ajax({ type: "post", url: $(this).attr("href").replace("AddToCart", "ExistsInCart"), data: { ProductId: $(this).parent().attr("data-productid") }, succes: function (data) { if (data == 1) { $("#ProductExistsInOrder").dialog({ autoOpen: true, height: 170, width: 400, modal: true, buttons: { "OK": function () { /*acties om toe te voegen $.ajax()*/ $.ajax({ type: "post", url: $(this).attr("href"), data: { ProductId: ProductID, Ammount: Ammount }, succes: function () { $("#AddProductNotification").text("U heeft net een product toegevoegd. Herlaad de pagina om uw winkelwagentje te bekijken"); } }); setTimeout("location.reload(true);", 100); $(this).dialog("close"); location.reload(true); // return false; }, "Annuleer": function () { $(this).dialog("close"); // return false; } } }); } else { $.ajax({ type: "post", url: $(this).attr("href"), data: { ProductId: ProductID, Ammount: Ammount }, succes: function () { $("#AddProductNotification").text("U heeft net een product toegevoegd. Herlaad de pagina om uw winkelwagentje te bekijken"); } }); }; // $("#AddProductNotification").text("U heeft net een product toegevoegd. Herlaad de pagina om uw winkelwagentje te bekijken"); }, error: function (XMLHeeptRequest, textStatus, errorThrown) { alert(textStatus); alert(errorThrown); } }); // alert("end"); // AddToCart(this); return false; }); // return false; }); // ProductId: $(orderlinkObject).parent().attr("data-productid"), Ammount: $(orderlinkObject).parent().parent().find("input#ammount").val() </code></pre> <p></p> <p>This is how it goes:</p> <ul> <li>Gets called (=ok) : /Cart/ExistsInCart with parameter: product ID and returns true in jSon</li> <li>But the dialog isn't called and i can't seem to update it with firebug.</li> </ul>