How to set global variables in jQuery/JavaScript? -
i have ajax function:
$.ajax({ url: 'http://localhost/process.php', type: 'post', data: '', success: function(output) { var animal = output } });
i var animal
set globally can call anywhere on page outside ajax function's success callback. how this?
declare outside of function or jquery construct
var animal = null; $(function(){ $.ajax({ url: 'http://localhost/process.php', type: 'post', data: '', success: function(output) { animal = output } }); });
Comments
Post a Comment