Hi everone how can I return data after ajax call success. I try to do it using async: false, but my browser is frozen.
I wan to do something like this
function ajaxtest()
{
var ActChatDepartmentArray = new Object();
$.ajax({
url: 'ajax/boldjsonfilewithoneparam/',
type: 'POST',
async: false,
headers: { "X-CSRFToken": '{{csrf_token}}' },
data: {
'DepartmentID': DepartmentID,
'paramString': "DepartmentID",
'operations': "getActiveChats"
},
dataType: 'json',
success: function (response) {
$.each(response.Data, function(key, value){
ActChatDepartmentArray[value.OperatorID] = { OperatorID: value.OperatorID, ChatID: value.ChatID};
});
},
error: function (jqXhr, textStatus, errorMessage) { // error callback
alert('Error: ' + errorMessage);
},
complete : function(jqXHR, textStatus){
}
});
return ActChatDepartmentArray;;
}
then I want to be able to call my function as:
var i = ajaxtest();
Best regard,