For some reason my function is returning undefined while seemingly working in itself.
function getDomains() {
    $.ajax({
        url:    '/rewrites/cgi-bin/ajax.pl?action=listdomains',
        dataType:'json',
        async:  false,
        success: function( data ) {
            if (data.error) {
                alert(data.error);
            }
            else {
                alert(data.domains);
                return(data.domains);
            }
       }
   });
}
alert(getDomains());
My first alert shows a populated list but the second is undefined. Does this make any sense?
 
     
    