mardi 21 juillet 2020

How can I return a response from a call in order to open xml file using jquery

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



Aucun commentaire:

Enregistrer un commentaire