I have a screen that lists the Trademarks registered in the system, as soon as the user opens this screen, the list of marks should happen. I already have AJAX done and it was working, however I wanted to get it from inside the marcas.php
page and leave it in a file where it will only have the AJAX
of my system. However I am not sure how to capture the JSON that AJAX returns, it follows the structure of the files:
marcas.php
<script type="text/javascript">
$(document).ready(function(){
$("input[name='inputPesquisar']").val('');
$("input[name='inputDataInicial']").val('');
$("input[name='inputDataFinal']").val('');
console.log(listarMarcas());
});
</script>
ajax.js
function listarMarcas(){
var retornoAjax;
$.ajax({
type: "GET",
url: "../api/api.marcas.php",
data: {"ajax-params": 1},
dataType: "JSON",
success: function(res){
retornoAjax = res;
},
error: function(res){
retornoAjax = res;
}
});
return retornoAjax;
}
The way it is, when the user opens the page marcas.php
, console.log
shows only UNDEFINED
, however this listing ajax returns a JSON, how can I capture it there on page marcas.php
ajax is on page ajax.js
?