I have problem if i start project ajax first post get exception error undefined, BUT other posts work well. And if i set async:false i dont get errror but window.location doesnt work.
$.ajax({
contentType: 'application/json; charset=utf-8',
dataType: 'json',
type: "POST",
headers: headers,
data: json,
url: "/Controller/Action",
cache: false,
success: (result) => {
if (result.zprava === "good") {
window.location.assign(result.url);
return false;
}
else if (result.zprava === "low") {
alert("Lowly!");
return false;
}
else if (result.zprava === "bad") {
alert("bad ");
return false;
}
return false;
},
error: (exception) => {
alert("Mistake!" + " || " + exception + console.log(json));
}
});
I have tried everything but no one help me...
I try wrapping
ajax().done(function (result) {
window.location.assign(result.url);
}).fail(function () {
alert("chyba");
});
function ajax() {
return $.ajax({
ERROR IS ONLY AT FIRST TIME and then all going good...My Controller sending json but this POST not waiting ... This ajax doesnt want know about any response he instantly fired ERROR but method call back sucefull....and tell me again about sync ... If i tried set async: false its good but i need after succes windows.location.append() and this isnt work... :/ sorry for my english i am trying do my best! :D and thanks much I'll be glad for any response not like as ajax... :D :D