简体   繁体   中英

jquery mobile load page external into div

How do insert the external code of register.html page in a div when when it finishes successfully my call ajax ?

function onSuccess(data, status)
    {

         $.mobile.pageContainer = $("#content").pagecontainer();
        $.mobile.pageContainer.pagecontainer("load", "register.html");
    }

    function onError(data, status)
    {
        // handle an error
    }        

I use pageContainer but not load the html in #content div

If using JQuery, you can load in external pages/markup using the load method. This will allow you to then output it into a div.

$( "#result" ).load( "ajax/test.html" );

For more info, see

http://api.jquery.com/load/

You'll need to use enhanceWithin() otherwise JQuery mobile enhancement won't be performed on the new content:

$.get('pagename.html', function (response) {
        $('#result').html(response).enhanceWithin();
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM