Ajax function to return value – JavaScript – The SitePoint Forums

function cityconfirm(){
    var cityid = document.getElementById('city').value;
    alert(getcityvalue(cityid));
    return confirm('Are you sure you want to delete')
}

function getcityvalue(cityid){
    // this will generate another thread to run in another function
    jQuery.ajax({
        url: 'http://mysite.com/lookupcity.asp?cityid=' + cityid,
        type: 'get',
        dataType: 'text/html',
        success: function(data){
        //
        return(data);
        }
    });
    // it will always return here in function
    return "Hello";
}

Source: Ajax function to return value – JavaScript – The SitePoint Forums

Leave a Reply

Your email address will not be published. Required fields are marked *