0

我正在使用 jQueryMobile,我想使用表单在数据库中输入一些值。

我有一个可以工作并使用 test123.php 将数据提交到数据库的表单:

  <form method="get" action="test123.php?test=1">
         <input type="submit" value="spiegel" />
  </form>

我得到一个按钮,但新页面显示为普通页面。

使用此解决方案:

  <a  data-role="button" data-rel="dialog" href="#test">
           spiegel
  </a>

我得到一个具有相同输出的对话框(我得到消息“spiegel”)。

但我希望确认站点显示为对话框。

与 data-rel"dialog" 的链接,所以我想使用我的 php 站点,但我希望在提交数据后看起来像一个对话框,做一个数据库。我不知道该怎么做。

谢谢您的帮助

4

3 回答 3

1
<!DOCTYPE html> 
<html> 
<head>
  <!--add all your jquery,jquery mobile as well as its CSS refrences here-->
 </head>
<body>
<div data-role = "page">
    <div data-role="header">
<a href="#login" data-role="button" data-rel="dialog" data-transition="pop" data-icon="plus">opendialogpage</a>
</div>
    <div data-role="content">
<p>just for sample display</p></div>
</div>
    <div data-role="dialog" id="login">
    <div data-role="header" data-theme="e"></div>
    <div data-role="content">
        <form id="login_form">
            <fieldset>
                <div data-role="fieldcontain">
                <label>USER NAME:</label>
                <input type="text" id="name" value=""/>
                </div>
                <div data-role="fieldcontain">
                    <label>EMAIL ID:</label>
                    <input type="text" id="email" value=""/></div>
            </fieldset>  
</form>
</div>
</div>
</body>
于 2013-04-16T18:30:02.350 回答
0

好的,所以您希望 PHP 页面中的数据在对话框中而不是在下一页中打开。

您正在寻找的是 AJAX。

AJAX 允许您在不更改整个页面的情况下刷新和更改部分 HTML 页面。

$.ajax({
   url: 'test123.php',
   type: 'POST',
   data: {spiegel : 'spiegel'}
   error : function (){ document.title='error'; }, 
  success: function (data) {
    $('#ajax_content').html(data);
}

});

所以这个函数将返回到可变数据中生成的任何内容test123.php

链接到文档:http ://api.jquery.com/jQuery.ajax/

于 2012-12-21T01:47:02.563 回答
0

我也为此挣扎了一段时间。最后看了一下jquery mobile为对话框页面创建的html。只需创建一个具有以下结构的页面,它将始终作为对话框页面打开(就像它是从带有 的链接打开的一样data-rel="dialog")。

<!DOCTYPE html> 
<html> 
<head> 
<title>Page Title</title> 
<!-- include your css, jquery, and jquery mobile files here -->
</head> 
<body> 
<div data-role="dialog">
<div data-role="content">   
<!-- content goes here -->
</div><!-- /content -->
</div><!-- /dialog -->
</body>
</html>

您所做的只是更改data-role="page"data-role="dialog".

于 2013-04-15T00:31:02.887 回答