function submitForm(){
    var urlid = document.getElementById("actionUrl").value;
    jQuery.support.cors = true;
    setTimeout(function(){
      $.ajax({
        url:urlid,
        type : "GET",
        crossDomain : true,
        data:transId,
        success:function(data)
        {
            alert(data);
        },
        error: function (xhr, ajaxOptions, thrownError)
        {
            console.log(thrownError);
            alert(xhr.status);
            alert(ajaxOptions);
            alert(thrownError);
        }
        });
    },1000);
};
I have an ajax call that receives one among the three responses 'true', 'false' or 'pending' from the controller. The ajax should terminate if the response is 'true' or 'false' . If the response is 'pending' the ajax should poll the controller for another 20 seconds. I should be able to pass the response to a different javascript function. Is it possible to do this in ajax/jquery ? I am new to this technology.