I have the following code:
my_string.replace(/^\[poll:([^\]]+)\]/mgi, function(match, capture) {
    return $.ajax({
        type: 'GET',
        url: '/my_url,
        data: {
            text: match
        },
        success: function(response) {
            return response;
        }
    });
});
I am doing an AJAX call in the anonymous function which returns the content that I would like to replace the string with but it is not working. It appears that I am returning the AJAX function rather than the response content.
 
    