I have a section of my code that sends info via jQuery Ajax to call the getMute function on the server but I'm having trouble with my getter. I want it to return a boolean that will allow me to create a button toggle but instead, I'm getting a console error that says 'result' is undefined. It works when I return just the data but I need the boolean specifically. Any tips on what I'm doing wrong?
function setMute(check) {
$.ajax({
url: url,
data: JSON.stringify(createData('setMute', check)), // Check is a Boolean
type: "POST",
dataType: "json",
success: function (data) {
console.log(data);
}
});
}
function getMute() {
response = $.ajax({
url: url,
data: JSON.stringify(createData('getMute', null)),
type: "POST",
dataType: "json",
});
response.done(function (data) {
console.log(data.response);
return data.response.result;
});