函数参数问题
public function listorder($id,$listorder){}参数中$id和$listorder是怎么来的啊
5
收起
正在回答
2回答
你好,首先是通过$("input").blur(function(){ 当输入域失去焦点 事件触发js方法,
$('.listorder input').blur(function() {
// 编写我们的抛送的逻辑
//获取主键id
var id = $(this).attr('attr-id');
// 获取排序的值
var listorder = $(this).val();
var postData = {
'id' : id,
'listorder':listorder,
};
var url = SCOPE.listorder_url;
//获取url连接:/index.php/admin/category/listorder.html
// 抛送http
$.post(url, postData, function(result){
// 逻辑
if(result.code == 1) {
location.href=result.data;
}else {
alert(result.msg);
}
},"json");
})然后通过ajax请求 post请求相当于执行:
$.post('/index.php/admin/category/listorder.html', postData, function(result){
///index.php/admin/category/listorder.html通过连接找到admin下的category控制器下的//listorder方法
//postData 表示 传递的参数( $id,$listorder)
// 逻辑
if(result.code == 1) {
location.href=result.data;
}else {
alert(result.msg);
}
},"json");
});然后调用图中方法:

如果解决您的问题请采纳,祝学习愉快!
PHP常用技术与ThinkPHP5框架开发
- 参与学习 人
- 提交作业 225 份
- 解答问题 3372 个
掌握用PHP开发互联网网站的必备功能,掌握当下主流的Linux系统开发,并熟练使用热门框架ThinkPhp开发电商团购项目,是通向PHP工程师必经之路。
了解课程


恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧
0 星