-1

我从 base(MongoDB) 获取信息。在成功部分,我得到一个 tmp_value。如何从 $.ajax 中获取这个 tmp_value。我的意思是,tmp_result 必须是 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
4

1 回答 1

-1

尝试这个...

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
于 2013-10-23T12:27:02.653 回答