php的ajax
应该怎么运用,下面编程教程网小编给大家详细讲解一下!
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语法之ajax的运用方法”的全面内容,想了解更多关于 php入门 内容,请继续关注编程基础学习网。
沃梦达教程
本文标题为:php语法之ajax的运用方法
基础教程推荐
猜你喜欢
- PHP实现根据数组的值进行分组 2022-08-01
- PHP如何实现网站分页的一个代码参考 2022-08-08
- php怎么判断一个数组中的元素是否完全属于另一个数组 2024-12-04
- php读取数据库里的数据以JSON格式返回数据 2024-05-12
- php代码实现页面跳转的5种方法 2024-12-04
- php多个数组求总平均数代码介绍 2024-12-05
- php解决json gbk编码中文null问题的实例代码 2022-11-22
- php利用api接口做一个发送短信功能 2024-12-05
- php如何实现多重接口(附代码介绍) 2024-12-05
- php实现计数器的实例代码 2022-08-27