6
I’m having trouble calling my variable pt1 outside the function(data) and within the function getImageItem.
Whereas the function(data) is inside the 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 in item = pt1; //NÂO PEGA A VARIAVEL.
Declare the variable in the scope of the getImageItem method
– Vinícius
javascript.. I’ll try Vinicius
– kaiquemix
@Vinícius is not certain, and pt1 is not existing in Function(date)
– kaiquemix