如何使用javascript显示jquery页面(在div内)?

这是我的问题,我称之为这种方法,它的作用是什么

使用jQuery在服务器上发布一些数据,我想使用从服务器接收的结果显示页面

我的页面index.html

// other page content

这里是来自javascript的代码片段, 快速的东西loginSubmit()调用loginPostData ,loginSubmit创建一个json对象并将其传递给loginPostData

 function loginPostData(jsonRequest) { $.post("http://localhost:8080/edserve/MobileServlet", JSON.stringify( jsonRequest), function(data) { var obj = JSON.stringify(data); //var object = JSON.parse(json_text); //alert(obj); alert(obj); if(data.status=="success") { //display main page //$('#mainMenu').show(); <-- this does not give desired result } else { if(data.message=="user not verified") { //display verification page } if(data.message=="no user exist with this usname") { //set focus to username $("#username").focus(); } } }, "json"); } 

如何在成功时显示主菜单,整个html代码在不同div的单个文件中


使用此代码重定向/显示特定的div标签/元素

$.mobile.changePage("#mainMenu",{allowSamePageTransition: true });

并且还下载了以下css文件,它必须在pages / div元素之间进行转换

jquery.mobile.transitions.css

试试这段代码

  $.mobile.changePage( "#mainMenu", { allowSamePageTransition: true }); 

并检查此链接

http://jquerymobile.com/test/docs/api/methods.html

您可以尝试使用此http://api.jquery.com/load/的jquery加载函数

试试这个..

 function loginPostData(jsonRequest) { $.post("http://localhost:8080/edserve/MobileServlet", JSON.stringify( jsonRequest), function(data) { var obj = JSON.stringify(data); //var object = JSON.parse(json_text); //alert(obj); alert(obj); if(data.status=="success") { $.mobile.changePage( "#mainMenu"); // main menu div id.. } else { if(data.message=="user not verified") { //display verification page } if(data.message=="no user exist with this usname") { //set focus to username $("#username").focus(); } } }, "json"); }