Join our mailing list

Stay up to date with latest software releases, news, software discounts, deals and more

Download 360 Browser 7.5.2.110

Visual web ripper duplicate check

 -  100% Safe  -  Free
  • Latest Version:

    Visual web ripper duplicate check LATEST

  • Requirements:

    Windows XP / Vista / Windows 7 / Windows 8

  • User Rating:

    Click to vote
  • Old Versions:

  • Javascript - how to make ajax synchronous? - stack overflow

    This question already has an answer here:

    How do I make function out of this?

    //check if station is alive $.ajax({ url: "lib/grab.php", data: "check_live=1&stream_url="+valueSelected, type: "GET", success: function (resp) { if (resp == 1) { play_this(valueSelected); } else { // } }, error: function (e) { console.dir(e); } });

    I thought I could do something like this:

    function is_alive(valueSelected) { result = false; //check if station is alive $.ajax({ url: "lib/grab.php", data: "check_live=1&stream_url="+valueSelected, type: "GET", success: function (resp) { if (resp == 1) { result = true; } else { // } }, error: function (e) { console.dir(e); } }); return result; }

    But obviously due to asynchronous nature of ajax call, result always returns false.

    What is the trick of dealing with this situation?

    Seems to work:

    //check if station is alive function is_alive(url) { // var result = false; // return $.ajax({ url: "lib/grab.php", data: "check_live=1&stream_url="+url, type: "GET", success: function (resp) { if (resp == 1) { // result = true; // } }, error: function (e) { console.dir(e); } }).then(function() { return $.Deferred(function(def) { def.resolveWith({},[result,url]); }).promise(); }); }

    And call it like this:

    //Change song on select, works both for fav and station lists $(document).on("click", ".ui-listview li a", function(){ var valueSelected = $(this).data("station-url"); // is_alive(valueSelected).done(function(result,url){ if (result) { // play_this(valueSelected); // } }); });


Join our mailing list

Stay up to date with latest software releases, news, software discounts, deals and more