Kshitij Pandey Kshitij Pandey - 1 year ago 81
Ajax Question

How can I access AJAX defined variable gloabally?

I created a variable in AJAX success function which I want to use for another AJAX call outside that function. I tried to store it with local storage and then use it but could not access the variable. Any idea as to how can I access it?

Here is the code:-

var c_id = 110;
type : "POST",
dataType : 'json',
data : {'id':c_id},
url : ' Back End/sbms.php',
success : function(data){
var quant_presta = data.quantity;
error : function(data){

Answer Source

Show the code ..

 url : '',
 success: function(data){

function myFunction(data){
  // do the processing here. You can access this from all ajax calls.