[eluser]Unknown[/eluser]
I have the following problem, I have a Controller:
Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Json extends CI_Controller {
function index(){
$arr = array('a' => 1, 'b' => 2, 'c' => 3, 'd' => 4, 'e' => 5);
echo json_encode($arr);
}
}
and a javascript file in which I call the controller,
Code:
$.get('http://localhost/tddd27/index.php/Json/index', function(data) {
console.dir(data);
});
The problem is that the result is the following:
Code:
{"a":1,"b":2,"c":3,"d":4,"e":5}</html>
The result contains a </html> tag and I can not understand why. I am new to codeigniter, I just want to create a module that gets a product list from a database, a controller that generate a json representation of the products table, and a javascript file which call the controller and is called within a view