-1

I get information from base(MongoDB). In success part I get a tmp_value. How to get this tmp_value out off $.ajax. I am meaning, that tmp_result must be 10.

**javascript**

    var tmp_object = null;  
    var tmp_result = null;
    $.ajax({url: VASERVER_API_LOC + '/visualization/' + visid + '/',
           type: 'GET',
           contentType: "application/json",
           data: tmp_object,
           success: function(tmp_object) { 
           var tmp_value = tmp_object.features; // tmp_value is 10
            });     


    });
tmp_result = tmp_value;
console.log(tmp_result);  //must be 10
seliboba98
  • 99
  • 1
  • 2
  • 8

1 Answers1

-1

Try this...

var tmp_object = null;  
var tmp_result = null;
$.ajax({
    url: VASERVER_API_LOC + '/visualization/' + visid + '/',
    type: 'GET',
    contentType: "application/json",
    data: tmp_object,
    success: function(tmp_object) {
        if(tmp_object.d == 10) {
            var tmp_value = tmp_object.d; // .d Should should contain data sent back
        }
    }
});
tmp_result = tmp_value;
console.log(tmp_result);  //must be 10
Mr.GT
  • 310
  • 4
  • 12