如何使用JavaScript显示jQuery页面(在div内)? [英] how to display jquery page(inside a div) using javascript?
问题描述
这是我的问题,我叫此方法,它的作用是
here is my problem, i call this method and what it does is
使用jQuery在服务器上发布一些数据,我想使用从服务器接收到的结果显示页面
post some data on server using jQuery, i want to display page using result i recieve from server
我的页面index.html
my page index.html
<div data-role="page" id="login">
// other page content
<div id="divrightButton">
<!-- calling loginSubmit which calls loginPostData-->
<a class="bluebutton" href="#" onclick="loginSubmit(); return false;">Login</a>
</div>
</form>
</div>
<!--main page-->
<div data-role="page" id="mainMenu">
Main menu
</div>
这是来自javascript的一段代码,快速的事件loginSubmit()调用loginPostData ,loginSubmit创建一个json对象并将其传递给loginPostData
here is the piece of code from javascript, quick thing loginSubmit() calls loginPostData ,loginSubmit make a json object and pass it to 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的单个文件中
HOW TO SHOW MAIN MENU WHEN THERE IS SUCCESS, the entire code of html is in single file in different div's
使用此代码重定向/显示特定的div标签/元素
use this code to redirect/display the particular div tag/element
$.mobile.changePage("#mainMenu",{allowSamePageTransition: true });
并下载以下css文件,这是在页面/div元素之间进行转换的必要条件
and also download following css file, its a must for transitioning between pages/div elements
jquery.mobile.transitions. css
推荐答案
尝试此代码
$.mobile.changePage( "#mainMenu", { allowSamePageTransition: true });
并检查此链接
http://jquerymobile.com/test/docs/api/methods.html
这篇关于如何使用JavaScript显示jQuery页面(在div内)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!