Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I finally accomplished what I needed. Here is the code. </p> <p><strong>view</strong></p> <pre><code>&lt;!-- model content --&gt; &lt;div id="form-content" class="modal hide fade in" style="display: none; "&gt; &lt;div class="modal-header"&gt; &lt;a class="close" data-dismiss="modal"&gt;×&lt;/a&gt; &lt;h3&gt;Card ID&lt;/h3&gt; &lt;/div&gt; &lt;div&gt; &lt;form class="contact"&gt; &lt;div class="modal-body"&gt; &lt;ul class="nav nav-list"&gt; &lt;input id="email" type="hidden" name="email" value="&lt;?php echo $email; ?&gt;"&gt; &lt;input id="location" type="hidden" name="location" value="&lt;?php echo $location; ?&gt;"&gt; &lt;label&gt;Please enter a valid Card ID:&lt;/label&gt; &lt;input id="CardId" type="input" name="CardId" maxlength="6"/&gt; &lt;/ul&gt; &lt;/div&gt; &lt;/form&gt; &lt;/div&gt; &lt;div class="modal-footer"&gt; &lt;a href="#" class="btn" data-dismiss="modal"&gt;Close&lt;/a&gt; &lt;button class="btn btn-success" id="submit"&gt;Save Changes&lt;/button&gt; &lt;/div&gt; &lt;/div&gt; &lt;?php if ($account -&gt; CardId) { echo $account -&gt; CardId; } else { echo "&lt;div id='thanks'&gt;&lt;p&gt;&lt;a data-toggle='modal' href='#form-content' class='label label-addvisit'&gt;Card ID&lt;/a&gt;&lt;/p&gt;&lt;/div&gt;"; } ?&gt; </code></pre> <p><strong>Script</strong></p> <pre><code>$(function() { $("button#submit").click(function(){ $.ajax({ type: "POST", url: "../edituser/addCardId", data: $('form.contact').serialize(), success: function(msg){ $("#thanks").html(msg) $("#form-content").modal('hide'); }, error: function(){ alert("failure"); } }); }); </code></pre> <p>});</p> <p><strong>Controller</strong></p> <pre><code>public function addCardId() { if ($this-&gt;input-&gt;is_ajax_request()) { $email = $this-&gt;input-&gt;post('email'); $location = $this-&gt;input-&gt;post('location'); $CardId = $this-&gt;input-&gt;post('CardId'); echo "&lt;span class=\"label label-info\" &gt;Card Id Assigned&lt;/span&gt;"; } } </code></pre> <p>All I have left to do is run some validations in the controller.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload