javascript - Ajax call Output into global variable -


how assign output of ajax call global variable output can used outside ajax call?

var filterarray=new array(); $.ajax({             type: "get",             url: uri,             datatype : "json",             contenttype : "application/json",                        data: {                 input:filtervalue             },               cache: false,             success : function(response) {                 filterarray = response;                 console.log(response);                  });             },             error: function(error) {                  console.log(error);             }             });     } 

let's have simple example ajax documentation:

$.ajax({   url: "test.html",   context: document.body }).done(function() {   $( ).addclass( "done" ); }); 

as see adding context sets this reference within callbacks:

the reference within callbacks object in context option passed $.ajax in settings; if context not specified, reference ajax settings themselves.

you append variable window.


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -