Welcome Guest, Not a member yet? Register   Sign In
It is not showing in the view
#1

[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.
#2

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

hope this helps




Theme © iAndrew 2016 - Forum software by © MyBB