时间:2021-07-01 10:21:17 帮助过:6人阅读
首先是前端页面,这个页面我们使用的是bootstrap和自己的若干技术,最后我们有一个按钮,它的源代码如下:
- $deal .= '';
相信有js基础的朋友们读懂这个代码不是问题,这里需要说明几点:
1.它使用了bootstrap,因此我们会看到诸如btn btn-danger btn-mini这些东西,
2.它调用了一个deleteOne()函数,而该函数中的参数$Id是PHP中的变量。
然后就是这个deleteOne方法的代码,注意这里我们导入了jQuery库,当然还有一些其他的库,这里只写其中比较重要的部分代码:
- public function delete(){
- if (! isPost ()) {
- $msg='输入的链接不正确!';
- showErrorMsg($msg);
- }
- $action='delete';
- $module=$this->module;
- $arrLang=lang('common_'.$module);
- $title=$arrLang[$action];
- $arr_post=$this->input->post();
- $arr_post=setForm($arr_post);
- $Id=@$arr_post['Id'];
- $status=FALSE;
- $logType=0;
- if(!isNullOrEmpty($Id)){
- $del_where=array('ID'=>$Id);
- $this->common_model->table='mx_changci';
- $result = $this->common_model->delete( $del_where );
- if ($result) {
- $status = TRUE;
- $message = $title.'成功!';
- } else {
- $status = FALSE;
- $message = $title.'失败!';
- }
- }else{
- $status=FALSE;
- $message= $title.'出错!';
- $logType=3;
- }
- $jsonData['status']=$status;
- $jsonData['message']=$message;
- header("Content-type: application/json");
- echo json_encode($jsonData);
- }
以上就介绍了辛星浅析一次ajax的实现过程,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。