www.webdeveloper.com
Results 1 to 2 of 2

Thread: Javascript blocking Call

  1. #1
    Join Date
    Aug 2011
    Posts
    1

    Unhappy Javascript blocking Call

    How do I do a blocking call in javascript?

    In the code below the alert at the last line of this code snippet hits before the code in if block completes which returns some value, by calling chached.get method in different js file.

    var getCachedData = function(_key){

    var retStr;
    if (_key != '' || _key != null) {
    cached.get(_key, function(data){
    if(data){
    alert('data = ' +data.value);
    return data.value;
    }
    else{
    return undefine;
    }
    });
    }
    alert('completed');
    }

    Please help

  2. #2
    Join Date
    May 2011
    Posts
    194

    call a function or pointer of function

    Hi,

    var getCachedData = function(_key)
    {
    var retStr;

    if (_key != '' || _key != null)
    {
    cached.get
    (_key,
    function(data)
    {
    if(data)
    {
    alert('data = ' +data.value);
    return data.value;
    }
    else
    {
    return undefine;
    }
    }
    );
    }

    alert('completed');
    }


    cached.get
    (_key,
    function(data)
    {...} // returns a pointer of function ?
    // no call ?


    var getCachedData = function(_key) ... // return a pointer of function

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles