jQuery Ajax和CodeIgniter

In this domain http://domain-two.com/test I have a js script that send a data to different domain.

var req = $.ajax(
    type: 'POST',
    url: 'http://domain-one.com/class/function',
    data: {...},
    dataType: 'json'
);

req.fail(function(jqXHR) {
    alert('Error');
});

For CI in:

function inquiry() {
    $res = array(...);
    $this->output->set_output(json_encode($res));
    return;
}

The problem is that I was always getting an error of 0.

try something like this

var req = $.ajax(
    type: 'POST',
    url: 'http://domain-one.com/class/function',
    data: {...},
    dataType: 'jsonp'
);