私はHMVCcodeigniterを使用しています。初めてjqueryajaxを使おうとしています。POSTを使用すると、GETの使用中にデータに応答するときに、未定義のエラーが発生します。
$.ajax({
type: "POST",
url: filelink+"cart/add_cart_item",
data: {"product_id":id,"quantity":qty,"ajax":"1"},
dataType: "json",
success: function(msg){
alert( "Data Saved: " + msg );
},
error: function(jqXHR, textStatus, errorThrown){
alert(textStatus + " " + errorThrown);
}
});
グーグルとSO-ingの後に私がこれまでに試したこと-
私のファイルのURLの場所に直接アクセスできます。確認しました。応答を与える。
Firebugは、同じファイルに対して500の内部サーバーエラーを出します。
Getを使用すると、返事が返ってきます
データ型にjsonを追加しました
コントローラ機能
class Cart extends CI_Controller { // Our Cart class extends the Controller class
function __construct()
{
parent::__construct();
$this->template->set('controller', $this);
}
function _remap()
{
$uri2 = $this->uri->segment(2);
if (is_numeric($uri2) OR $uri2 == FALSE) {
$this->index();
} else if ($uri2 == 'add_cart_item') {
$this->add_cart_item();
} else if ($uri2 == 'show_cart') {
$this->show_cart();
}
}
function add_cart_item(){
echo "asdfsadfdsf";
exit;
}
}
誰か助けてくれませんか?