このコードが機能しないのはなぜですか?このAjaxの条件付きダイアログが機能しないのはなぜですか?
一方、私はそれを改善しましたが、解決策を見つけることができませんでした。
誰でもアイデアはありますか?私はコンソールにエラーはありません。
まず、ダイアログを開く必要があるかどうかをチェックします。
これはワークフローです:
DialogRequired => Dialog.Click = OKならば - DialogRequired => Dialog.Click =キャンセルした場合> AJAX呼び出し を実行 - >何も しないダイアログが不要な場合は= >これは、それがどのようになるでAJAX呼び出し
$(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()
を実行します。
- パラメータ:製品IDを持つCart/ExistsInCartが呼び出され、jSonでtrueを返します。
- ダイアログが呼び出されず、Firebugで更新できないようです。
それはすべてのエラーをスローしていますか? – Abadon
何が問題なのですか?何が効いていますか? –
"not working"を定義してください。実際に何をしているのか、あなたのコンソールに何らかのエラーがあります。 –