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里面调用远程地址,方法前加上public啊!!
本网刊登的文章均仅代表作者个人观点,并不代表本网立场。文中的论述和观点,敬请读者注意判断。
本文地址:http://www.xlkjgs.com/notes/web/3071.html
以上内容由
本站整理呈现,请务必在转载分享时注明本文地址!如对内容有疑问,请联系我们,谢谢!
给这篇文章的作者打赏

微信扫一扫打赏

支付宝扫一扫打赏
×