I want to insert value into database and with $.getJson() method I check if my value exist into database and if not I want to call $.ajax to put it into database I tried like this and modal dialog pops up but method continue with execution and I my application is broken every time how to prevent execution after modal dialog pops up I try to put $.ajax inside else block but nothing then I tried like this but nothing?
enter $("#btnSave").click(function (e) {
e.preventDefault();
var form = $(this).closest("#forma1");
$.ajax({
type: "POST",
url: form.attr("Create"),
data: $.getJSON("/InspekcijskeKontrole/Check?id1=" + $("#kombo3").val() + "&id2=" + $("#kombo4").val(), function (data) {
if (data.InspekcijskoTijeloId != -1 && data.ProizvodId != -1) {
$.getJSON("/Proizvodi/VratiIme/" + data.ProizvodId, function (ime) {
if (ime != null) {
$("#modalni1 p").text("Inspekcijska kontrola za " + ime + " je vec izvrsena");
$("#modalni1").modal({ backdrop: "static" });
}
});
}
}),
data:form.serialize(),
success: function (response) {
alert("Informacije su uspjesno ubacene");
window.location.href = "/InspekcijskeKontrole/Index";
},
error: function (greska) {
alert("Doslo je do greske pri ubacivanju");
}
});
});code here