javascript - Showing ajax call result in bootstrap modal -
javascript - Showing ajax call result in bootstrap modal -
i need show multiple info in bootstrap modal. did this:
js file:
$('#seeprofile').on('show', function() { $('.see-user').on('click', function(e) { e.preventdefault(); var id = $(this).data('id'); $.ajax({ url: 'getuser', type: 'post', data: {id: id}, success: function(html){ $('#seeprofile .modal-body .p').html('test'); }, error: function(){ alert("error"); } }); }); }); view snippet (modal):
<div id="seeprofile" class="modal hide fade" tabindex="-1" data-replace="true"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button> <h3>perfil de usuario</h3> </div> <div class="modal-body"> <p></p> </div> <div class="modal-footer"> <button type="button" data-dismiss="modal" class="btn">close</button> </div> this not working. modal not showing up, when inspecting no errors appear. doing wrong?
edit
given answers have realized missed dot, success function should like:
$('#seeprofile .modal-body p').html("test"); now modal working need know how "insert" info new modal organization:
<div id="seeprofile" class="modal hide fade" tabindex="-1" data-replace="true"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button> <h3>perfil de usuario</h3> </div> <div class="modal-body"> <div class="scroller" style="height:300px" data-always-visible="1" data-rail-visible="1"> <div class="row-fluid"> <div class="span6"> <h5>usuario</h5> <p><input type="text" class="span12 m-wrap" id="username" readonly></p> <h5>nombre</h5> <p><input type="text" id="name" class="span12 m-wrap" value="" readonly></p> </div> <div class="span6"> <h5>email</h5> <p><input type="text" class="span12 m-wrap" readonly></p> </div> </div> </div> </div> <div class="modal-footer"> <button type="button" data-dismiss="modal" class="btn">close</button> </div> as can see there many "< p >" tags within modal-body. have tried inserting id can distinct it's not working me. how can this?
you should replace
$('#seeprofile .modal-body .p').html('test'); by
$('#seeprofile .modal-body p').html('test'); because you're looking class called 'p' if insert dot before. html tag <p></p> have write 'p' in selector.
and finish "$('#seeprofile').modal('show');" show modal.
javascript jquery ajax twitter-bootstrap bootstrap-modal
Comments
Post a Comment