I want to open xml file with jquery , but when I want to display the value of open outside the function , I have an undefined error .
Here the code :
$(document).ready(function () {
var open ;
$.ajax({
type: "GET",
url: "../build/js/openTickets.xml",
dataType: "xml",
success: nv =function(xml) {
$(xml).find("mestickets").each(function () {
open=($(this).find("nbopenTickets").text());
console.log(open);//It works
});
}
})
console.log(open);//undefined