我已經閱讀了一些非常類似於SO的問題,但沒有一個解決方案適用於我。CodeIgniter給了我錯誤404,但我可以在Firebug中看到響應
的問題是,例如,使用此代碼視圖:
$.ajax({
url: 'periodista/json',
async: false,
dataType: 'json',
success: function (json) {
$.each(json, function(k,v){valores.push(v); });
}
我得到一個404 Not Found錯誤,但螢火蟲顯示我的答覆(http://i.imgur.com/ yG9cW.png)
我試圖讀取從的file_get_contents函數的簡單的PHP腳本的URL響應,但它不工作
$url="http://localhost/xampp/populus/wordpress/app/periodista/json";
$json = file_get_contents($url);
我得到相同的答案(404錯誤,我可以閱讀中的回覆螢火蟲)。
我已經嘗試使用「index.php」URLs,沒有index.php的URL與htaccess的幫助,並使用完整的網址,但沒有任何工作。而且我沒有使用wordpress。
我想控制器沒有加載,當我嘗試訪問視圖,但我不知道爲什麼。
編輯:我的控制器功能代碼(我用點燃的數據表庫):
public function json()
{
$datatables = new Datatables();
$datatables->select('nro_boletin')->from('proyecto_de_ley');
echo $datatables->generate();
$data['title'] = "Periodista";
$this->load->view('periodista/json', $data);
}
你可以在你的控制器顯示代碼? – Stanley
@ user1877722請在您的問題中添加該代碼(通過編輯),而不是作爲註釋 –
您不應該加載視圖。嘗試'$ this-> output-> set_content_type('application/json') - > set_output(json_encode($ data));' – Stanley