js 與 php 通過json數(shù)據(jù)進(jìn)行通訊示例
更新時(shí)間:2014年03月26日 17:12:55 作者:
這篇文章主要介紹了js與php通過json數(shù)據(jù)進(jìn)行通訊的具體實(shí)現(xiàn),需要的朋友可以參考下
js 與 php 通過json數(shù)據(jù)進(jìn)行通訊
例子:
php文件
<?php
echo json_encode(array(array(
'liaotiantiao'=>$liaotiantiao,
'liaotiank'=>$liaotiank,
'chatuserid'=>$chatuserid,
'chattouserid'=>$chattouserid
)));
?>
html 文件
$(document).ready(function(){
//默認(rèn)條聊天條聊天框狀態(tài)
$.post('/index.php/chat/morenltt',{},function(val){
var obj=eval(val);
alert(obj[0].chatuserid);
});
});
例子:
php文件
復(fù)制代碼 代碼如下:
<?php
echo json_encode(array(array(
'liaotiantiao'=>$liaotiantiao,
'liaotiank'=>$liaotiank,
'chatuserid'=>$chatuserid,
'chattouserid'=>$chattouserid
)));
?>
html 文件
復(fù)制代碼 代碼如下:
$(document).ready(function(){
//默認(rèn)條聊天條聊天框狀態(tài)
$.post('/index.php/chat/morenltt',{},function(val){
var obj=eval(val);
alert(obj[0].chatuserid);
});
});
您可能感興趣的文章:
相關(guān)文章
JavaScript學(xué)習(xí)筆記之ES6數(shù)組方法
ES6給數(shù)組添加了一些新特性,而這些新特性到目前為止完全可以運(yùn)用到自己的業(yè)務(wù)層。在這一節(jié)中將總結(jié)有關(guān)于ES6給數(shù)組提供一些新特性的使用方法2016-03-03
將CKfinder整合進(jìn)CKEditor3.0的新方法
最新發(fā)布的CKFinder 1.4版 已經(jīng)提供了對CKEditor3.0的支持2010-01-01
基于iScroll實(shí)現(xiàn)內(nèi)容滾動(dòng)效果
這篇文章主要為大家詳細(xì)介紹了基于iScroll實(shí)現(xiàn)內(nèi)容滾動(dòng)效果,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2018-03-03
JS簡單獲取當(dāng)前日期時(shí)間的方法(如:2017-03-29 11:41:10 星期四)
這篇文章主要介紹了JS簡單獲取當(dāng)前日期時(shí)間的方法,涉及javascript針對當(dāng)前日期時(shí)間的簡單運(yùn)算操作,需要的朋友可以參考下2017-03-03
輕松實(shí)現(xiàn)HTML和JS之間的轉(zhuǎn)化的代碼
輕松實(shí)現(xiàn)HTML和JS之間的轉(zhuǎn)化的代碼...2007-09-09

