I have the following script which is not working for some reason:
success: function( widget_data )
{
if( widget_data.d[0] ) {
var j = 0;
for ( j = 0; j <= widget_data.d.length - 1; j++ ) {
$.getScript( "js/" + widget_data.d[j].script, function() {
// this line is complaining about .widget_id
alert(widget_data.d[j].widget_id);
});
// but this line works fine...
alert(widget_data.d[j].widget_id);
}
}
}
I get an error on the following line, with one withing .getScript
:
alert(widget_data.d[j].widget_id);
The error message is:
Cannot read property 'widget_id' of undefined
But the strange thing is, the following alerts work fine and return the correct values:
alert(widget_data.d[j].widget_id);
What am I doing wrong?