1 回答
TA贡献1806条经验 获得超8个赞
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | public function actionSample(){ if (Yii::$app->request->isAjax) { $data = Yii::$app->request->post(); $searchname= explode(":", $data['searchname']); $searchby= explode(":", $data['searchby']); $searchname= $searchname[0]; $searchby= $searchby[0]; $search = // your logic; \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; return [ 'search' => $search, 'code' => 100, ]; } } 模板调用 $.ajax({ url: '<?php echo Yii::$app->request->baseUrl. '/supermarkets/sample' ?>', type: 'post', data: {searchname: $("#searchname").val() , searchby:$("#searchby").val()}, success: function (data) { console.log(data.search); } }); |
- 1 回答
- 0 关注
- 731 浏览
添加回答
举报