I am populating a table with a Jquery Template. In this template, I need to use a json file through a ajax call to populate.
$(document).ready(function() {
var clientData;
$.get("/webpro/webcad/lngetusuario", function(data, status){
clientData = data;
alert(clientData);
});
$("#clientTemplate").tmpl(clientData).appendTo("tbody");
});
<script id="clientTemplate" type="text/html">
<tr><td> ${usuario} </td><td> ${nome} </td><td> ${setor} </td></tr>
//{{tmpl($data) "#phoneTemplate"}}
</script>
The url '/webpro/webcad/lngetusuario' generate the json file.
This is the code. I don't understand this, because inside $.get statement the variable clientData are with the correct value json, but outside $.get statement(on document.ready) the variable clientData are empty.
Can anyone help me with this?