Welcome Guest, Not a member yet? Register   Sign In
CI + ajax
#4

It is possible.
TS is asking create Modal, not asking get from Model.

You can use it in view like this:
HTML and JS:
PHP Code:
<div class="bs-example">
 <!-- 
Button HTML (to Trigger Modal) -->
 <
a href="#myModal" class="btn btn-lg btn-primary" data-toggle="modal">Launch Demo Modal</a>

 <!-- 
Modal HTML -->
 <
div id="myModal" class="modal fade">
 <
div class="modal-dialog">
 <
div class="modal-content">
 <
div class="modal-header">
 <
button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
 <
h4 class="modal-title">Confirmation</h4>
 </
div>
 <
div class="modal-body">
 <
div id="ajax_content"></div>
 <
p>Do you want to save changes you made to document before closing?</p>
 <
class="text-warning"><small>If you don't save, your changes will be lost.</small></p>
 </div>
 <div class="modal-footer">
 <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
 <button type="button" class="btn btn-primary">Save changes</button>
 </div>
 </div>
 </div>
 </div>
 </div>

 <script type="text/javascript">
 $(document).ready(function() {
 $.get('
<?php echo site_url(); ?>sample_modal/get_ajax_result', function(data) {
 $('#ajax_content').html(data);
 });
 });
 </script> 

Controller:
Sample_modal method get_ajax_result
PHP Code:
public function get_ajax_result() {
 echo 
'Content from ajax';
 exit();

Reply


Messages In This Thread
CI + ajax - by GrigoreMihai - 03-12-2015, 06:05 AM
RE: CI + ajax - by CroNiX - 03-12-2015, 02:55 PM
RE: CI + ajax - by comp_nerd26 - 03-13-2015, 02:22 PM
RE: CI + ajax - by jinbatsu - 03-13-2015, 07:12 PM



Theme © iAndrew 2016 - Forum software by © MyBB