简体   繁体   English

jQuery移动加载页面外部成div

[英]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 ? 成功完成我的调用ajax如何在div插入register.html页面的外部代码?

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 我使用pageContainer但未在#content div加载html

If using JQuery, you can load in external pages/markup using the load method. 如果使用JQuery,则可以使用load方法加载外部页面/标记。 This will allow you to then output it into a div. 这样您就可以将其输出到div中。

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

For more info, see 有关更多信息,请参见

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

You'll need to use enhanceWithin() otherwise JQuery mobile enhancement won't be performed on the new content: 您将需要使用EnhanceWithin(),否则将不会在新内容上执行JQuery移动增强:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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