Returning the html from .ajax call

后端 未结 3 914
既然无缘
既然无缘 2021-01-03 04:14

I\'m getting undefined for some reason when I try to return the html via the callback function:

function getDataFromUrl(urlWithContent)
{  
    // jQuery asy         


        
3条回答
  •  太阳男子
    2021-01-03 04:46

    Why dont you try this:

    function getDataFromUrl(urlWithContent)
    {  
        // jQuery async request
        $.ajax(
        {
            url: urlWithContent,
            dataType: "html",
            success: function(data) {
                                        $('#dialogDiv').html(data);
                                    },
            error: function(e) 
            {
                alert('Error: ' + e);
            }
        });
    }
    

    And just call the function and not assign it to any variable.

    HTH

提交回复
热议问题