B
B
Black_Fire2021-09-29 12:10:40
AJAX
Black_Fire, 2021-09-29 12:10:40

How to pass a variable from a callback to an external code?

In the console, step is equal to undefind, but it is necessary that the data from the incoming response be saved. If you need to use async / await, then where exactly in this example?

let step;
    
    $.ajax({
      url: "https://kachay.com.ua/calculation_info.php",
      dataType: "json",
      type: "get",
      success: function(res) {
        step = res.data.sum_step
      }
    })
    console.log(step)

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