php的ajax
应该怎么运用,下面web建站小编给大家详细讲解一下!
javascript端
var cityInfo=$('#cityInfo').val(); var typeInfo=$('#typeInfo').val(); if(!(cityInfo==''&& typeInfo=='')){ $.ajax({ url:'/index.php?m=member&c=index&d=111', type:'POST', dataType:'json', data: {cityInfo:cityInfo,typeInfo:typeInfo}, success:function(data){ var str=''; for(i in data){ str += "<div class='caseIntroduce'>"; str += "<a href='index.php?m=member&c=index&a=exchange_show&type=accept&id="+data[i]['id']+"'>"; str += "<div class='caseinfo1'>"; str += "<span class='casetitle'>"+data[i]['title']+"...</span>"; str += "</div>"; str += "<div>"; str += "<span class='caseblue'>"+data[i]['classification']+"</span>"; str += "<span>金额:"+data[i]['accountMoney']+"</span>"; str += "<span>费用:"+data[i]['entrustcost']+"元</span>"; str += "<span>"+data[i]['linkage']+"</span>"; str += "<span>"+data[i]['receivetime']+"</span>"; str += "</div>"; str += "</a>"; str += "</div>"; } $(".caseCenter").html(str); } }) }
php端
public function receive_search(){ $cityInfo=$_POST['cityInfo']; $typeInfo=$_POST['typeInfo']; $sqlCity=$cityInfo == '' ? '' :"linkage='$cityInfo'"; $sqlType=$typeInfo == '' ? '' : "classification='$typeInfo'"; if(!empty($sqlCity)&&!empty($sqlType)){ $sql=$sqlCity.'AND '.$sqlType; }else{ $sql=$sqlCity.$sqlType; } $order = 'updatetime desc'; $catid = 181; if(!$this->set_modelid($catid)) return false; $datas = $this->db_con -> select($sql,'*', '', $order, '', ''); foreach($datas as $key=>$val){ $datas[$key]['title']=displayPart($val['title'],15); $datas[$key]['classification']=get_linkage($val['classification'],6650,'-',1); $datas[$key]['accountMoney']=get_linkage($val['accountMoney'],6766,'-',1); $datas[$key]['linkage']=sliceArea(get_linkage($val['linkage'],3360,'-',1)); $datas[$key]['receivetime']=date('Y-m-d',$val['receivetime']); } echo json_encode($datas); exit; }
php语法对index.php首页进行判断(根据需要显示不同页面)
上面是“php语法之ajax的运用方法”的全面内容,想了解更多关于 php入门 内容,请继续关注web建站教程。
当前网址:https://ipkd.cn/webs_2540.html
workflows工作流
- 一只千纸鹤坐在路上哭泣ComfyUI工作流
- 一座古老的石阶,旁边有一棵树
- 1个粉红色头发可爱的女孩ComfyUI工作流
- 坐落在白雪覆盖的广阔平原上2只可爱的雪豹
- 一把令人难忘的美丽吉他ComfyUI工作流
- 一架受损严重的宇宙飞船内有一只猫
- 一只蓬松柔软的圆形半鳄梨玩偶
- 一只可爱的猫骑着一匹可爱的马ComfyUI工作流
猜你喜欢
声明:本站提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请发送到邮箱:admin@ipkd.cn,我们会在看到邮件的第一时间内为您处理!