javascript - Array doesn't keep content, maybe something with declaration -


this question has answer here:

i have array declared in else structure

var days = new array(); $.ajax({       url: 'someurl',       datatype: 'jsonp',       success: processjson }); 

i process data ajax call in processjson function

function processjson(jsondata) {     var weather = jsondata.data.weather;     for(var key in weather) {         var day = weather[key];          days.push(new array(day.tempmaxc, day.type));     } } 

i add other arrays days-array.

if check in console (in processjson-function), length three/

then when want use variable in code under the ajax-call, nothing works , when check length it's 0. guess it's declaration?

is code under ajax call happening after processjson function? call processjson function asynchronous , happens after ajax call finishes. code following might happen before. might timing thing. if need array other processing should have in callback or after know callback has been finished.


Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

VBA function to include CDATA -