Returning the html from .ajax call
<p>I'm getting undefined for some reason when I try to return the html via the callback function:</p>

<pre><code>function getDataFromUrl(urlWithContent)
{  
    // jQuery async request
    $.ajax(
    {
        url: urlWithContent,
        dataType: "html",
        success: function(data) {
                                    return $('.result').html(data);
                                },
        error: function(e) 
        {
            alert('Error: ' + e);
        }
    });
}
</code></pre>

<p>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.</p>

<p>When I call my function, I am doing the following:</p>

<pre><code>var divContent = getDataFromUrl(dialogDiv.attr("href"));

if(divContent)
    dialogDiv.innerHTML = divContent;
</code></pre>

<p>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?</p>

<p>I also tried just return data;  same thing, I get undefined after the call to this method when set to my variable.</p>

<p>Updated per responses:</p>

<p>Tried this, still getting undefined:</p>

<pre><code>function getDataFromUrl(urlWithContent, divToUpdate)
{  
    $.ajax(
    {
        url: urlWithContent,
        aSync: false,
        dataType: "html",
        success: function(data) {
                                    divToUpdate.innerHTML = data;
                                },
        error: function(e) 
        {
            alert('Error: ' + e);
        }
    });
}
</code></pre>

<p>I called it from within another function like this:</p>

<pre><code>var divContent = "";

if (dialogDiv.attr("href"))
{
    getDataFromUrl(dialogDiv.attr("href"), divContent);
}
</code></pre>
