I create a simple ajax call, which retrieves data from my database with json, something like:
$.ajax({
type: "..",
url: "..",
data: ..,
success:function(data){
var arrayData = jQuery.parseJSON(data);
}
});
Then I get an array to arrayData, but how can I use it out of the 'success function'?
You have to declare the arrayData var before the ajax call.
var arrayData;
$.ajax({
type: "..",
url: "..",
data: ..,
success:function(data){
arrayData = jQuery.parseJSON(data);
}
});
I recommend you read some on variable scope in javascript.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With