The problem is big, but solve is simple.
I have old function that works and has to be return true or false..
function char_existz(char_name, server) {
$.ajaxSetup({async: false});
$.getJSON("/index.php?f=payment&char_name=" + char_name + "&s=" + server, function (json) {
res = json.k;
});
$.ajaxSetup({async: true});
console.log(res === 1);
return (res === 1);
}
In using of it i get warning: [Deprecation] Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience.
I want to make it without warning, tried on $.ajax with something like this
function char_existzz(char_name, server) {
$.ajax({
type: "POST",
url: '/payment',
data: {char_name: char_name, s: server},
success: function (data) {
result = (data.k===1);
},
dataType: 'json'
});
return result;
}
ce = char_existz(character.val(), server.val());
if (ce === false) {
alert('Player not found!');
return false;
}
but it doesn't return true or false in variable, so i don't know how to be, because on old functions it's works, when i don't touch async