youtube / spfjs

A lightweight JS framework for fast navigation and page updates from YouTube
https://youtube.github.io/spfjs/
MIT License
2.23k stars 147 forks source link

spf.load return undefined #440

Open TonyGao opened 7 years ago

TonyGao commented 7 years ago

Hi, there

I have a try with SPF 24 (v2.4.0), when I use spf.load api, it's return undefined, but the xhr is work normally and the response is proper for me, code below(use in background template system). The question is how can I get the response content and append it to the specific dom, perhaps like pjax way?

$('#append').click(function () {
    $('#title-body').layout('expand', 'south');
    console.log(spf.load("{{ path('admin_org_title_new') }}"));
});
athy125 commented 8 months ago

Replace #yourTargetElement with the actual ID or selector of the DOM element where you want to append the content.

$('#append').click(function () {
    $('#title-body').layout('expand', 'south');

    spf.load("{{ path('admin_org_title_new') }}", function(response) {
        if (response) {
            $('#yourTargetElement').html(response);
        } else {
            console.error('Failed to load content');
        }
    });
});