1

My Browser shows deprecation warning, when i do ajax call. I need the script to wait for the feedback before the value can be stored in variable for next progress

Here's my chunck of code:

    url='https://data.com/txt';
    var templastprice=0;
    var tempvalue=0;
     jQuery.ajax({
        type: 'GET',
        url: url,
        dataType: 'json',
        success: function(data){
            templastprice=data['ticker']['last'];
            tempvalue=="0";

          },
          async: false
    });

I don't think this is a good approach for the future, any suggestion to fix this ?

Thanks

Viktor Iwan
  • 89
  • 2
  • 10

1 Answers1

0

Use JQuery deferred.promise https://api.jquery.com/deferred.promise/ or queue, aynch, flow js to make synchronous calls. Similar answers can be found at How do I return the response from an asynchronous call?

Anup Yadav
  • 2,825
  • 3
  • 21
  • 30