jquery ajax post not working with .load in codeigniter

Posted by bravo on Stack Overflow See other posts from Stack Overflow or by bravo
Published on 2010-12-22T16:38:46Z Indexed on 2010/12/22 16:54 UTC
Read the original article Hit count: 286

Filed under:
|
|
|
|

i wish to .load multiple views result with jquery ajax

the original code (js)

$(document).ready(function(){
$("#uid").change(

function(){

    var uid=$("#uid").val();

    $.ajax({
    type: "POST",
    url: "<?= site_url('sp_profile/ajax_userdetail') ?>",
    dataType: "json",
    data: "uid="+uid,
    cache:false,
    success:
      function(data){

        $("#content").html(data);
      }

    });

  return false;

});
});

this return only one result in

what if i want to load 3 results like in

<div id="content"></div> 
<div id="content1"></div> 
<div id="content2"></div> 
  • content could be userid
  • content2 could be user first name
  • content3 could be user last name

my js should using .load instead of html right? let me know if i'm wrong.

success:
          function(data){

            $("#content").load("<?= site_url('sp_profile/ajax_userdetail')?>");
            $("#content2").load("<?= site_url('sp_profile/ajax_userdetail')?>");
            $("#content3").load("<?= site_url('sp_profile/ajax_userdetail')?>");
          }

i stuck with this thing for whole day..

please anyone show me the right way to do the controller and js code.

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about AJAX