I declare an array then make an ajax call which returns multiple rows of values. I'm trying to add the id of these rows to that array that i declared previously, but it keeps returning undefined.
  var recipeIds = Array();
    $.ajax({
        url: url,
        type: 'POST',
        contentType: "application/json",
        dataType: 'jsonp',
        crossDomain: true,
        jsonp: 'jsoncallback',
        cache:true,
        success: function(data, status){
            $.each(data, function(i,item){
                             recipeIds.push(item.id);
         });
        },
        error: function(){
            console.log("Ajax not working - recipies in cat");
        }
    });
    alert("array0 = " + recipeIds[0]);
any suggestions?
 
    