Welcome Guest, Not a member yet? Register   Sign In
[Solved] Refreshing Just A Div With Codeigniter
#4

It seams you are doing 2 request to the server the ajax post and load in the success handler.
Would it not be better to return the updated content of the div with the ajax response

Some thing like this:


Code:
<script type="text/javascript">
$(document).ready(function() {
   $('#vote-up-icon').on('click', function(e) {
       e.preventDefault();
       $.ajax({
           url: "<?php echo base_url('thread/voteup/');?><?php echo $thread_id;?>",
           type: 'post',
           dataType: 'json',
           data: {
               voteup: $(this).parent().find('#vote_up').val()
           },
           success: function(response){
                resp = $.parseJSON(response);
               if (resp.success == true) {
                   $('.rep').html(resp.div_content);
               }
           }  
       });
   });
});      
</script>


Your php method echo a json_encode($result_array)
A good decision is based on knowledge and not on numbers. - Plato

Reply


Messages In This Thread
RE: Refreshing Just A Div With Codeigniter - by salain - 10-12-2016, 04:13 AM



Theme © iAndrew 2016 - Forum software by © MyBB