$(document).ready(function() {
$('#csubmit1').on('click',function (event) {
// alert("test");
event.preventDefault();
var formData = {
orderfrom1: $("#orderfrom1").val(),
orderto1: $("#orderto1").val(),
agentlist1: $("#ag1").val(),
};
console.log(formData);
$.ajax({
type:"POST",
url:"<?php echo base_url(); ?>home/obwirelessreports",
data:formData,
success:function (data) {
$('#search_change1').html(data);
}
});
});
});
Controller.php
$details=$this->input->post();
$data["orderfrom1"]=date("Y-m-d",strtotime($details['order_from']));
$data["orderto1"]=date("Y-m-d",strtotime($details['order_to']));
$data["agentlist1"]=$this->Maindata->wiresearch1($details);
型号.php
$orderfrom=date("Y-m-d",strtotime($data2['order_from']));
$orderto=date("Y-m-d",strtotime($data2['order_to']));
$agent_list = implode(', ', array_map(function($val){return sprintf("'%s'", $val);}, $data2["agentlist1"]));
我不知道如何将数据从ajax传递到控制器。这是正确的路吗?我曾尝试在单个数组中使用数据,但它不起作用。我应该做哪些改变?
您发送的是参数orderfrom𝟏,orderto𝟏,agentlist𝟏
,但读取的是orderfrom,orderto,agentlist
,它们必须完全匹配。
$data["orderfrom1"]=date("Y-m-d",strtotime($details['order_from1']));
$data["orderto1"]=date("Y-m-d",strtotime($details['order_to1']));
$data["agentlist1"]=$this->Maindata->wiresearch1($details);
我不知道模型中的data2
是什么,但密钥可能也必须匹配。