Doing this:
<script type="text/javascript">
var d;
$.get("/some/other/url/that/returns/json", function(json){
d = json;
}, "json");
</script>
you'll get the json
response, and if its already an array, you wont be needing to do anything else. Also, please use eval()
as little as possible. (Not at all is great)
Be carefull that d
wont have any value until there is a response, so your code should deal with that. Most likely, you'll call the function that uses d
from within $.get("...", function(json){},"json").
<script type="text/javascript">
var d;
useArray = function(d){
//Operations that involve the response
}
$.get("/some/other/url/that/returns/json", function(json){
d = json;
// Operate over "d" once your server
useArray(d);
}, "json");
</script>
Of course, as you now have all operations over d
on a separate function, you could simply do this
<script type="text/javascript">
useArray = function(d){
//Operations that involve the response
}
$.get("/some/other/url/that/returns/json", function(json){
useArray(json);
}, "json");
</script>
If you need to acces again to d
, you should modify your code as needed. This is only a guide.