Welcome Guest, Not a member yet? Register   Sign In
Problem updating a div with ajax (json_encode)
#2

[eluser]LuckyFella73[/eluser]
Your Ajax controller has to return the result as json.
You can't just load a view in your controller to get a json result.

Your controller function should more look like:
Code:
public function GetOnlineUsers()
{
$this->load->model('home_page_model');
die(json_encode($this->home_page_model->onlineUsers())); // return result to ajax function
}

If you want to format (HTML) the result before the data is send to the js function
you can do that too.

EDIT:
I looked at your controller code and saw your json_encode function so
I thought you expect a json as the result for your js function. But
now I see you use the jquery "load" function. So my code might not
help you.

Can you post what kind of errors do you get?


Messages In This Thread
Problem updating a div with ajax (json_encode) - by El Forum - 10-31-2012, 11:13 AM
Problem updating a div with ajax (json_encode) - by El Forum - 11-01-2012, 02:17 AM



Theme © iAndrew 2016 - Forum software by © MyBB