I have an ajax call and I want to use result of this ajax on another page.
//This is main.js file
function myFun(){
var my_user = "Stas";
var itemsUrl = "myxmlwithusers";
var user_found = false;
$.ajax({
url: itemsUrl,
method: "GET",
headers: { "Accept": "application/json; odata=verbose" },
cache: false,
async: false,
dataType: "text",
success: function(data){
var jsonObject = JSON.parse(data);
results = jsonObject.d.results;
$(results).each(function(){
if($(this)[0].user == my_user){
user_found = true;
}
});
},
error:function () {
console.log("Error");
}
}
);
}
// This is execute.js file
myFun();
if (user_found == true){cool}
I need true or false for // user_found. Let say I will put in the file execute.js my function myFun() and in main.js my user is fetch with "$(this)[0].user" and I need to receive "true" in execute.js
Thanks!