CodeIgniter Forums
It is not showing in the view - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: It is not showing in the view (/showthread.php?tid=59357)



It is not showing in the view - El Forum - 09-24-2013

[eluser]Unknown[/eluser]
Hello all,

I don't know what the problem is. I have an ajax which sends username to the controller:

Code:
function my_profile(username){
    
        $.ajax({
          
           url: "member/my_profile",
           type: "get",
           data: "username="+username,
           success: function(){
               windowdotlocation.href = 'member/my_profile';
           }
        });
    }

And this is my controller:

Code:
function my_profile(){
        
        
        $username = $this->input->get('username');
        $data['username'] = $username;
        $this->load->view('my_profile' , $data);
    }

I have already echo the $username to test that it can alert(msg) from the ajax. It works just find. Problem is nothing is shown in my view:

Code:
<h1>My Profile</h1>

&lt;?php

echo $username;
?&gt;

I don't know why. I tried initialized $data['username'] = 'adam' and this works.


It is not showing in the view - El Forum - 09-24-2013

[eluser]jairoh_[/eluser]
in your ajax call try chaning
Code:
data: "username="+username
w/
Code:
data: { username: username }

hope this helps