【发布时间】:2018-07-20 10:54:55
【问题描述】:
我正在开发 Codeigniter。我的代码是:
这是我对下拉更改事件(查看页面)的 ajax 方法调用
$('#drp').change(function(e){ //dropdown change event
var costcenter = $('#costcenter_id :selected').val(); //parameter 1
var location1 = $('#location_id :selected').val(); //parameter 2
var department = $('#department_id :selected').val(); //parameter 3
$.ajax({
cashe: false,
type: 'POST',
data: {'costcenterid':costcenter,
'locationid':location1,'departmentid':department},
url: 'http://local.desk.in/index.php/mycontroller/contollerfunction',
success: function(data)
{
alert("success");
}
});
});
这是我的控制器方法(控制器中的方法)
public function controllerfunction($costcenterid,$locationid,$departmentid)
{
echo "costcenter= ".$costcenterid;
echo "location= ".$locationid;
echo "department= ".$departmentid;
}
收到错误信息:
Message: Missing argument 1 for assetcontroller::controllerfunction(),
Message: Missing argument 2 for assetcontroller::controllerfunction(),
Message: Missing argument 3 for assetcontroller::controllerfunction()
为什么我无法将 ajax 参数值发送到控制器方法?
【问题讨论】:
-
也显示你的控制器方法
-
请始终通过提供一些 cmets 来回应答案,或者,如果对您有帮助,请将其标记为绿色并点赞,这是感谢所有程序员的最佳方式
标签: php ajax codeigniter codeigniter-3