欧美大屁股bbbbxxxx,狼人大香伊蕉国产www亚洲,男ji大巴进入女人的视频小说,男人把ji大巴放进女人免费视频,免费情侣作爱视频

歡迎來到入門教程網(wǎng)!

phpcms

當前位置:主頁 > CMS教程 > phpcms >

phpcms調(diào)用getJSON無法返回json數(shù)據(jù)的解決方法

來源:本站原創(chuàng)|時間:2020-01-10|欄目:phpcms|點擊: 次


復制代碼
代碼如下:

/**
* 檢查hash值,驗證用戶數(shù)據(jù)安全
*/
final private function check_hash() {
if(preg_match('/^public_/', ROUTE_A) || ROUTE_M =='admin' && ROUTE_C =='index' || in_array(ROUTE_A, array('login'))) {
return true;
}
if(isset($_GET['pc_hash']) && $_SESSION['pc_hash'] != '' && ($_SESSION['pc_hash'] == $_GET['pc_hash'])) {
return true;
} elseif(isset($_POST['pc_hash']) && $_SESSION['pc_hash'] != '' && ($_SESSION['pc_hash'] == $_POST['pc_hash'])) {
return true;
} else {
showmessage(L('hash_check_false'),HTTP_REFERER);
}
}

phpcms給函數(shù)進行了hash驗證,因此,現(xiàn)在方法是這樣寫的:

復制代碼
代碼如下:

public function public_mobile_getjson_ids() {//publc是后來加上去的
$modelid = intval($_GET['modelid']);
$id = intval($_GET['id']);
$this->db->set_model($modelid);
$tablename = $this->db->table_name;
$this->db->table_name = $tablename.'_data';
$r = $this->db->get_one(array('id'=>$id),'mobile_type');

if($r['mobile_type']) {
$relation = str_replace('|', ',', $r['mobile_type']);
$relation = trim($relation,',');
$where = "id IN($relation)";
$infos = array();
$this->mobile_db = pc_base::load_model ( 'mobile_type_model' );
$datas = $this->mobile_db->select($where,'id,type_name');
//$this->db->table_name = $tablename;
//$datas = $this->db->select($where,'id,title');
foreach($datas as $_v) {
$_v['sid'] = 'v'.$_v['id'];
if(strtolower(CHARSET)=='gbk') $_v['type_name'] = iconv('gbk', 'utf-8', $_v['type_name']);
$infos[] = $_v;
}
echo json_encode($infos);
}
}

js部分的getJSON是這樣寫的:


復制代碼
代碼如下:

//顯示添加機型
function show_mobiletype(modelid,id) {
$.getJSON("?m=content&c=content&a=public_mobile_getjson_ids&modelid="+modelid+"&id="+id, function(json){
var newrelation_ids = '';
if(json==null) {
alert('沒有添加相關文章');
return false;
}
$.each(json, function(i, n){
newrelation_ids += "<li id='"+n.sid+"'>·<span>"+n.type_name+"</span><a href='javascript:;' class='close' onclick=\"remove_relation('"+n.sid+"',"+n.id+")\"></a></li>";
});

$('#mobile_type_text').html(newrelation_ids);
});
}

就好了。要注意phpcms里面調(diào)用遠程地址,方法前加上public?。?!

上一篇:PHPCMS取消搜索時的分詞功能的方法

欄    目:phpcms

下一篇:phpcms V9實現(xiàn)qq登陸oauth2.0的方法

本文標題:phpcms調(diào)用getJSON無法返回json數(shù)據(jù)的解決方法

本文地址:http://mengdiqiu.com.cn/a1/phpcms/9800.html

網(wǎng)頁制作CMS教程網(wǎng)絡編程軟件編程腳本語言數(shù)據(jù)庫服務器

如果侵犯了您的權(quán)利,請與我們聯(lián)系,我們將在24小時內(nèi)進行處理、任何非本站因素導致的法律后果,本站均不負任何責任。

聯(lián)系QQ:835971066 | 郵箱:835971066#qq.com(#換成@)

Copyright © 2002-2020 腳本教程網(wǎng) 版權(quán)所有