I'm not able to call my variable pt1
out of function(data)
and within function getImageItem
.
Being function(data)
is within function getImageItem
.
function getImageItem() {
var item = "";
jQuery.ajax({
url: "pegaPortifolio.php/?id=1", //?id="+idUltimo,
dataType: "json", //Tipo de Retorno
success: function(data) {
var pt1 = "";
var i = 1;
var ultimo_id = 0;
var size = 0,
key;
for (key in data) {
if (data.hasOwnProperty(key)) size++; //cod para contar o tamanho do array multidimensional
} //size , variavel com o tamamho do array
for (i = 0; i < size; i++) { //monta o html para exibir os dados
pt1 += '<div class="element-item ' + data[i].menu + '" data-category="transition"><div style="padding:2.5px;"><div style="border: 1px solid #AAAAAA;"><a href="#portfolioModal54" class="portfolio-link" data-toggle="modal"><img src="' + data[i].imageM + '" alt="project 2"><div class="fundo-port"><h1>"' + data[i].tipo + '"</h1><h2>"' + data[i].nome + '"</h2></div></a></div></div></div>';
}
}
});
//alert(pt1);
item = pt1; //NÂO PEGA A VARIAVEL
return item;
}
Part I want the variable to be called is item = pt1; //NÂO PEGA A VARIAVEL
.