Saving AJAX JSON to an array

Saving AJAX JSON to an array

How do I save the JSON which I'm receiving through ajax to an existing array? I first need to delete everything in my array savedData and save the JSON into that.

Here's the code :-


  
  1. function getArticleOnPageLoad() {
  2. $.getJSON("http://www.myurl.com/myJSON.json", function(data) {
  3. savedData = data;
  4. createData();
  5. }).fail(function(error) {
  6. console.log("AJAX ERROR: " + error);
  7. });
  8. }