This question has already been answered:
There is a function that represents the framework of ajax requests:
/*Структура для ajax-запросов: method - тип запроса (get,post,update,delete), убрано в связи с jsonp async - boolean, вкл/откл асинхронность, address - url запроса, transport_data - данные на отправку, function_on_success - функция, которая выполнится при удачном запросе, parameters_for_fun_as_obj - объект с набором параметров для удачной функции*/ function create_ajax(async,jsonp_callback,address,transport_data,function_on_success,parameters_for_fun_as_obj){ $.ajax({ method: 'get', dataType: 'jsonp', //jsonp: false, jsonpCallback: jsonp_callback, contentType: "text/json; charset=utf-8", async: async, url: address, global: true, crossDomain: true, data: transport_data, success: function (data) { function_on_success(data, parameters_for_fun_as_obj); } }); How to assign the value of a local variable in the query results function using this framework? Thus it is impossible to make - the request is executed, the function is also, the data is not empty, but is not assigned.
function my_function(){ var temp; temp = create_ajax(true,'result',address,'',return_data); } var return_data = function(data){ return data; }