Welcome Guest, Not a member yet? Register   Sign In
Using JSON in CI
#1

[eluser]cip6791[/eluser]
Hi all,

I just started using CI and would like a little help with something. I am sending data via JSON from a different domain like this:

Code:
script type="text/javascript" src="http://mysite.com/test.php?js"/script

In test.php I have a function that sends some info to callback.php

Quote:function doAjax(){
$.getJSON("http://mysite.com/callback.php?name=myname&location=location&callback;=?",
function(message) {
alert("Data Saved");
});
<button>Send</button>'); <-- This loads the doAjax function.

The callback.php gets the name and location from http://mysite.com/callback.php?name=myna...n&callback;=?.

I created a new public function and a view because I also need the logged in user. But I can't seem to get it working. I am not very experimented in this so i apologize if this is not very clear.

Code:
public function callback()
{
  $data['user_id'] = $this->tank_auth->get_user_id();
  $data['username'] = $this->tank_auth->get_username();
  $this->load->view('callback_view', $data);
}

Everything works if I leave the files the way they are. I just want to integrate it in CI. Any help is appreciated. Thanks!




Theme © iAndrew 2016 - Forum software by © MyBB