Welcome Guest, Not a member yet? Register   Sign In
Need help with my first Ajax get
#1

[eluser]kolxoznik1[/eluser]
My js script

Code:
jQuery(".unblock").click(function(){
        var num = jQuery('.page.active').text();
        var ban_id = jQuery(this).attr('id');

      
        

        jQuery.get("http://127.0.0.1/auth_system_1/user_activity/delete_user_ban", { ban_id : ban_id, num : num }, function(data) {

                jQuery("#ban_list").append(data);

        }, "json");

    });

My delete_user_ban function

Code:
function delete_user_ban()
    {
        $user_id = $this->session->userdata('user_id');
        
        $ban_id = $this->input->post('ban_id');
        
        $current_page = (int)$this->input->post('num');
        
        //$this->activity_model->delete_user_ban($ban_id);
        
        $per_page = 2;
        
        $data['ban_list'] = $this->user_activity_lib->user_ban_list($user_id, $current_page, $per_page);

        $this->load->view('front_end/ajax_delete_ban', $data);

    }

and I want to return it here

Code:
<!--begin ban list-->
        <div id="ban_list">
        
        
        &lt;?php foreach($ban_list as $value): ?&gt;
  <div class="comment-box small-comment" id="info-ban-1">
      <div class="photo-box">
   <img src="&lt;?=$value['user_image'];?&gt;" alt="" class="photo rounded"/>
   <a href="#" title="" class="corner rounded"></a>
      </div>
      <div class="comment rounded">
   <div class="bg-tl"></div>
   <div class="avatars">
       <a href="#" title="">&lt;?=$value['user'];?&gt;</a><span>blocked</span><a href="&lt;?=base_url() . $value['ban_user'];?&gt;" title=""><img src="&lt;?=$value['user_ban_image'];?&gt;" alt=""/>&lt;?=$value['ban_user'];?&gt;</a>
       <a href="[removed];" title="Unblock" class="unblock" id="&lt;?=$value['ban_id'];?&gt;">unblock</a>
   </div>
      </div>
      <div class="both"></div>
  </div>
        &lt;?php endforeach; ?&gt;
        
        </div>
  &lt;!--end ban list--&gt;
  &lt;?=$pagination;?&gt;
     </div>

What can I say, everything works good EXCEPT data not returned to <div id="ban_list"></div> .

If I delete this line in function :

$this->load->view('front_end/ajax_delete_ban', $data);

and add echo '1';

it return where I want '1' but content from here $this->load->view('front_end/ajax_delete_ban', $data); do not return to this div ? Why ?

I have watched response and html what return and here is html lines returning from view but do not appear in Query("#ban_list").append(data);

Please help me to solve this small problem
#2

[eluser]kolxoznik1[/eluser]
I have tested with this lines :

Code:
echo '1111';

return OK!

Code:
echo '1111 2222';

do not return ?

How to return more then one word and where is my mistake ?

#3

[eluser]CroNiX[/eluser]
Look at your jQuery.get(). You are telling it that json will be the returned data format. Is it? If not, try changing it to 'html' or something.
#4

[eluser]meigwilym[/eluser]
*edited
#5

[eluser]CroNiX[/eluser]
Not sure what you edited, you are still telling your $.get() that the returned datatype is expected to be json, but it doesn't look like you are returning json. It looks like you are returning html (since its a view).




Theme © iAndrew 2016 - Forum software by © MyBB