S
S
serking772018-01-29 10:39:05
JavaScript
serking77, 2018-01-29 10:39:05

How to display the received value in the global scope?

Hello!
Guys, tell me how can I display a variable from $.ajax.

var blabla,

        $.ajax({
            type: 'GET',
            dataType: "json",
            url: 'http://app.hhh.local/handler.php?number=' + value + '&organization_type=counters'
        }).done(function(data) {
            blabla = data;
        }).fail(function(data) {
            console.log('fail');
        });
console.log(blabla); //undefined


It seems to me that this is not possible, and the processing should be done in the done section, but this is not always convenient!
Or should I wrap $.ajax in a Promise.

Thank you.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question