Is there a way to return the success data that is obtained by the AJAX call?
I am trying to do the following:
function myFunction(title) {
var csrftoken = getCookie('csrftoken');
$.ajax({
url: 'call_details_cache/',
type: 'post',
data: {
phone: title,
type_member: "cust",
csrfmiddlewaretoken: csrftoken
},
success: function (data) {
},
failure: function (data) {
alert('Got an error dude');
}
});
}
And then:
console.log(myFunction(title))
undefined
is printed in my console. How can I fix it?
Thanks in advance!