2013年7月3日 星期三

jQuery $.ajax() asynchronous get url content

function showGetResult( name )
{
     var result = null;
     var scriptUrl = "somefile.php?name=" + name;
     $.ajax({
        url: scriptUrl,
        type: 'get',
        dataType: 'html',
        async: false,
        success: function(data) {
            result = data;
        } 
     });
     return result;
}




Reference :
jQuery return $.get data in a function - Stack Overflow
javascript - How can I get jQuery to perform a synchronous, rather than asynchronous, AJAX request? - Stack Overflow

沒有留言:

張貼留言