【发布时间】:2015-03-03 20:13:40
【问题描述】:
这是我的 javascript 函数.... 但是我的 php 控制器获取所有值但不是数组不知道为什么?需要帮忙..... 在此先感谢:)
function submitForm(){
var id = $('#id').val();
var supplier_id = $('#supplier_id').val();
var description = $('#description').val();
var numofpro = $('#numofpro').val();
var product_id = new Array();
for(var i=0;i<numofpro;i++){
product_id[i] = $('#product_id'+(i+1)).val();
}
var payment_mode = $('#payment_mode').val();
//description = description.replace(new RegExp('\r?\n','g'), '<br />');
$.ajax({
url: "<?= base_url(); ?>edit/save_purchase", //The url where the server req would we made.
data: "id="+id+"&supplier_id="+supplier_id+"&description="+description+"&product_id="+product_id+"&payment_mode="+payment_mode,
dataType: "html", //Return data type (what we expect).
beforeSend:function(){
//alert("asds");
},
success: function(data) {
//alert("Edited");
alert(data);
}
});
}
【问题讨论】:
-
试试
data: {id:id, supplier_id:supplier_id, description:description, product_id:product_id, payment_mode:payment_mode},而不是你的长字符串。应该是这样设置的。 -
它解决了我的问题...thnx :)
标签: javascript php arrays ajax codeigniter