I am having trouble with disabling asynchronous ajax. Here is the code snippet that I have:
function GetDataFromUninorte() {
link="http://www.uninorte.edu.co/documents/71051/11558879/ExampleData.csv/0e3c22b1-0ec4-490d-86a2-d4bc4f512030";
var result=
$.ajax({
url: 'http://whateverorigin.org/get?url=' + link +"&callback=?" ,
type: 'GET',
async: false,
dataType: 'json',
success: function(response) {
console.log("Inside: " + response);
}
}).responseText;
console.log("Outside: "+result);
return result;
}
However, I am encountering the following issue:
It seems that "Outside" always runs first and the result is undefined, making it impossible to process data.
I have attempted
When ... Then
Setting Async = false
Passing data as parameters in the I / O functions
and other methods, but nothing has worked
:/
... Thank you in advance
(I apologize for any mistakes in my English)
[Solved]
Perhaps not optimal, but within the "success:" statement, I call a function that receives the AJAX response and triggers the rest of the process. This way, I do not need to store the response in a variable and the asynchrony does not affect me.