Issue
$(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);
Model.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"]));
I don't Know how to pass the data from ajax to the controller . Is this the right way ? i have tried using the data in a single array but it is not working . What is the Changes that i should make ?
Solution
You're sending the parameters orderfrom𝟏,orderto𝟏,agentlist𝟏 but reading orderfrom,orderto,agentlist, they have to match exactly.
$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);
I don't know what data2 in the Model but the keys may have to match as well.
Answered By - Musa
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.