Welcome Guest, Not a member yet? Register   Sign In
Ajax newbie - nothing happening
#1

[eluser]richzilla[/eluser]
Hi All,

Ive never really looked at ajax much before, JS is not my strong point, and im having a bit of trouble with this function:
Code:
var user_data =
                                             {
                                                userid: 4
                                             };
                                         $.ajax({
                                            url: "<?php echo site_url('user/users/ajax'); ?>",
                                            type: "POST",
                                            data: user_data,
                                            success: function(retdata)
                                            {
                                                 $('input[name=customer_name]').val(retdata.name);
                                                 $('textarea[name=customer_address]').text(retdata.address);
                                                 $('input[name=customer_email]').val(retdata.email);
                                                 $('input[name=customer_tel]').val(retdata.tel);
                                                 $('input[name=user_id]').val(item.id);
                                            }


And the method in my code:
Code:
function ajax()
        {
            $user_id = $this->input->post('userid');
            $user = $this->user_model->get_user($user_id);

            $user_data = "[{name:\"".$user->sub_user_name."\",";
            $user_data .= "address:\"".$user->sub_user_address."\",";
            $user_data .= "email:\"".$user->user_email."\",";
            $user_data .= "tel:\"".$user->sub_user_tel."\"}]";

            return $user_data;
        }


Nothing happens when i call it with javascript, and im not entirely sure where to start looking.
The function works when i call it normally (without using JS).

Whats the best format to return the data from the server in?

any help would be appreciated.


Messages In This Thread
Ajax newbie - nothing happening - by El Forum - 04-15-2010, 04:29 AM
Ajax newbie - nothing happening - by El Forum - 04-15-2010, 05:21 AM
Ajax newbie - nothing happening - by El Forum - 04-15-2010, 08:13 AM
Ajax newbie - nothing happening - by El Forum - 04-15-2010, 08:26 AM



Theme © iAndrew 2016 - Forum software by © MyBB