加载一个外部页面,提高其内容,并将其插入到DOM。这种方法被称为内部的changepage()功能时,它的第一个参数是一个URL。这个函数不影响当前页面可以在后台加载页面。该函数返回一个对象,获取延期承诺在该页被增强,插入到文档中的解决。
加载“about/us.html”的页面到DOM
<!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <meta content="width=device-width, initial-scale=1"> <title>jQuery.mobile.loadPage demo</title> <link href="https://code.jquery.com/mobile/1.3.0/jquery.mobile-1.3.0.min.css"> <script src="https://code.jquery.com/jquery-1.9.1.min.js"></script> <!-- The script below can be omitted --> <script src="https://www.jb51.net/resources/turnOffPushState.js"></script> <script src="https://code.jquery.com/mobile/1.3.0/jquery.mobile-1.3.0.min.js"></script> </head> <body> <div data-role="page"> <div></div> </div> <script> $.mobile.loadPage( "about/us.html" ); </script> </body> </html>
加载一个“searchresults.php”页,要发送的表单数据是“search”字符。
<!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <meta content="width=device-width, initial-scale=1"> <title>jQuery.mobile.loadPage demo</title> <link href="https://code.jquery.com/mobile/1.3.0/jquery.mobile-1.3.0.min.css"> <script src="https://code.jquery.com/jquery-1.9.1.min.js"></script> <!-- The script below can be omitted --> <script src="https://www.jb51.net/resources/turnOffPushState.js"></script> <script src="https://code.jquery.com/mobile/1.3.0/jquery.mobile-1.3.0.min.js"></script> </head> <body> <div data-role="page"> <div></div> </div> <script> $.mobile.loadPage( "searchresults.php", { type: "post", data: $( "form#search" ).serialize() }); </script> </body> </html>
您可能感兴趣的文章: