javascript - Jquery移动表单数据在单个文件中的两个页面之间提交?

标签 javascript jquery html jquery-mobile

I want send the data 'home_page' page to 'get_data' page.how to get the data from home page and send to the second page using jquery

<div class="main">
<!-- first page -->
    <section id="home_page" data-role="page">
        <header data-role="header">
            <h1>Header</h1>
        </header><!-- /header -->
        <article role="main" class="ui-content">
        <!-- Form -->
            <form action="" method="post" accept-charset="utf-8">
             form data send here            
            </form>
        </article><!-- /content -->
        <footer data-role="footer">
            <h1>Footer</h1>
        </footer><!-- /footer -->
    </section><!-- second page -->
    <section id="get_data" data-role="page">
        <header data-role="header">
            <h1>Header</h1>
        </header><!-- /header -->
        <article role="main" class="ui-content">
            <p> display the data here from home page </p>
        </article><!-- /content -->
        <footer data-role="footer">
            <h1>Footer</h1>
        </footer><!-- /footer -->
    </section><!-- /page -->
</div>

最佳答案

您可以获取第 1 页上的表单数据并将表单值附加到第 2 页。完成后,您可以根据需要更改页面。在演示中,“提交”按钮转到第二页。

代码

$("#sub").on( "click", function( event ) {
var first = $('#first').val();
var last  = $('#last').val();

$("#formdata").empty();

var pagedata = $("<p>" + first + "</p><p>" + last + "</p>");    

pagedata.appendTo("#formdata");

$("#formdata").enhanceWithin();

$( ":mobile-pagecontainer" ).pagecontainer( "change", "#get_data", { transition: "pop" } );    
})

演示

http://jsfiddle.net/j6btvLym/

关于javascript - Jquery移动表单数据在单个文件中的两个页面之间提交?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26059383/

相关文章:

javascript - 使用 Angular 2 将搜索中的对象插入数组

javascript - Ext JS - 验证文本字段

javascript - 在 jquery 选择的插件中动态添加新选项,其中选择多个

jquery - 监听文本框上的输入按键

javascript - jQuery根据href更改链接的innerHTML

html - 如何在伪元素中使用 z-index

html - 输入类型文件在 Bootstrap 模式中不起作用

javascript - onclick href 未在单击函数内触发

javascript - 从特定类文本创建数组

javascript - 如何使用ajax更新数据库中的记录并在单击按钮时删除表行?