当我尝试将数据用于服务器时问题就开始了。一旦我取消注释这一行$data_product = $this->item->addProduct($descripcion,$cost_price,$selling_price,$wprice,$stock);
我得到问题500内部服务器错误,但我不知道为什么如果我有一切正常,ids,名称等我想将我的数组发送到服务器。我该如何调试此错误并修复它?我试过去查看我的日志,但没有任何内容......
这是链接:http://alasksoft.tk/inventory/product 登录凭据:admin - admin
控制器
public function addProduct(){
$descripcion = $this->input->post('description');
$cost_price = $this->input->post('cost_price');
$selling_price = $this->input->post('selling_price');
$wprice = $this->input->post('wprice');
$stock = $this->input->post('stock');
$data_product = $this->item->addProduct($descripcion,$cost_price,$selling_price,$wprice,$stock);
$data = array(
'description' => $descripcion,
'cost_price' => $cost_price,
'selling_price' => $selling_price,
'wprice' => $wprice,
'stock' => $stock
);
$this->json($data_product);
}
模型
public function addProduct($descripcion,$cost_price,$selling_price,$wprice,$stock){
$data = array(
'descripcion' => $descripcion,
'precio_compra' => $cost_price,
'precio_venta' => $selling_price,
'precio_mayoreo' => $wprice,
'existencia' => $stock
);
$query = $this->db->insert('storelte_articulos',$data);
return $query->result_array();
}
AJAX
$('#add').on('click',function(){
$("#description").mask("(999) 999-9999");
$("#new_product").validate();
BootstrapDialog.show({
message: function(dialog) {
var $message = $('<div></div>');
var pageToLoad = dialog.getData('pageToLoad');
$message.load(pageToLoad);
return $message;
},
data: {
'pageToLoad': URL_GET_VIEW_PRODUCT
},
closable: false,
buttons:[{
id: 'btn-ok',
cssClass: 'btn-primary',
icon: 'glyphicon glyphicon-send',
label: ' Save',
action: function (e) {
var description = $('#description').val();
var cost_price = $('#cost_price').val();
var selling_price = $('#selling_price').val();
var wprice = $('#wprice').val();
var stock = $('#stock').val();
if($("#new_product").valid()){
$.ajax({
url: URL_GET_ADD_PRODUCT,
type: 'POST',
data: {description: description, cost_price: cost_price, selling_price: selling_price, wprice: wprice, stock: stock}
}).done(function (e) {
console.log(e);
});
}
}
},{
id: 'btn-cancel',
cssClass: 'btn-danger',
icon: 'glyphicon glyphicon-remove',
label: ' Cancel',
action: function (e) {
e.close();
}
}]
});
});