Returning the html from .ajax call
- by coffeeaddict
I'm getting undefined for some reason when I try to return the html via the callback function:
function getDataFromUrl(urlWithContent)
{  
    // jQuery async request
    $.ajax(
    {
        url: urlWithContent,
        dataType: "html",
        success: function(data) {
                                    return $('.result').html(data);
                                },
        error: function(e) 
        {
            alert('Error: ' + e);
        }
    });
}
I know I'm getting data back, I see it in firebug in the response and also when I alert out the data, I see the entire page content come up in the alert box.
When I call my function, I am doing the following:
var divContent = getDataFromUrl(dialogDiv.attr("href"));
if(divContent)
    dialogDiv.innerHTML = divContent;
when I alert out the divContent (before the if statement) I'm getting undefined.  Maybe I'm just going about this wrong on how I'm returning back the data?
I also tried just return data;  same thing, I get undefined after the call to this method when set to my variable.