2016-08-13 22:49
浏览 394


I have a page using a modal to register new user Here is the modal code :

<div id="register" class="modal fade" role="dialog">
  <div class="modal-dialog">

    <!-- Modal content-->
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">&times;</button>
        <h4 class="modal-title">New User</h4>
      <div class="modal-body">

      <form id="new_customer" action="../model/php/action.php" method="post">
     <div class="form-group">
  <label for="usr">username:</label>
  <input type="text" name="user" class="form-control" id="usr">
 <div class="form-group">
  <label for="em">email :</label>
  <input type="text" name="email" class="form-control" id="em">
<div class="form-group">
  <label for="pwd">password :</label>
  <input type="password" name="pwd" class="form-control" id="pwd">
        <button type="submit"  id="signup" name="signup" class="btn btn-success btn-lg">signup<span class="glyphicon glyphicon-user"></span></button>
     </form>   </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-info" data-dismiss="modal">close</button>


and here example action page :

       if(empty($_POST['user']) || empty($_POST['email']) || empty($_POST['pwd']))
       echo $lang['empty'];

i want view back the results in the same dialog.

图片转代码服务由CSDN问答提供 功能建议

我有一个页面使用 modal 来注册新用户这是模态代码:

 &lt; div id =“register”class =“modal fade”role =“dialog”&gt; 
&lt; div class =“modal-dialog”&gt; \  n 
&lt;! - 模态内容 - &gt; 
&lt; div class =“modal-content”&gt; 
&lt; div class =“modal-header”&gt; 
&lt; button type =“ 按钮“class =”close“data-dismiss =”modal“&gt;&amp; times;&lt; / button&gt; 
&lt; h4 class =”modal-title“&gt;新用户&lt; / h4&gt; 
&lt; /  div&gt; 
&lt; div class =“modal-body”&gt; 
&lt; form id =“new_customer”action =“../ model / php / action.php”method =“post”&gt; \  n&lt; div class =“form-group”&gt; 
&lt; label for =“usr”&gt; username:&lt; / label&gt; 
&lt; input type =“text”name =“user”class =“  form-control“id =”usr“&gt; 
&lt; / div&gt; 
&lt; div class =”form-group“&gt; 
&lt; label for =”em“&gt; email:&lt; / label&gt;  
&lt; input type =“text”name =“email”class =“form-control”id =“em”&gt; 
&lt; / div&  gt; 
&lt; div class =“form-group”&gt; 
&lt; label for =“pwd”&gt; password:&lt; / label&gt; 
&lt; input type =“password”name =“pwd”class  =“form-control”id =“pwd”&gt; 
&lt; / div&gt; 
&lt; button type =“submit”id =“signup”name =“signup”class =“btn btn-success btn-lg”  &gt;注册&lt; span class =“glyphicon glyphicon-user”&gt;&lt; / span&gt;&lt; / button&gt; 
&lt; / form&gt;  &lt; / div&gt; 
&lt; div class =“modal-footer”&gt; 
&lt; button type =“button”class =“btn btn-info”data-dismiss =“modal”&gt; close&lt; / button&gt  ; 
&lt; / div&gt; 
&lt; / div&gt; 
&lt; / div&gt; 
&lt; / div&gt; 

此处示例 操作页面:

 if(isset($ _ POST ['signup']))
 if(empty($ _ POST ['user)  '])|| empty($ _ POST ['email'])|| empty($ _ POST ['pwd']))
 echo $ lang ['empty']; 


  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • douzhuochao4027 2016-08-13 23:04

    This ajax request for your question, if you don't understand it read about jquery and ajax requests.

    ajax request it will not call reload of the page, so your modal will still displayed:

        type: "POST",
        data: {user: $('#usr').val(), email: $('#em').val(), pwd: $('#pwd').val()},
        url: "/model/php/action.php",
        success: function(data){
              //here data will contain all output from .php, so for your script it will equal to $lang['empty'], you ca do whatever you want with data
              //f.e. set to modal
        error: function(data) {
            console.log(data); //error message
    打赏 评论

相关推荐 更多相似问题