js 與 php 通過json數(shù)據(jù)進行通訊示例
更新時間:2014年03月26日 17:12:55 作者:
這篇文章主要介紹了js與php通過json數(shù)據(jù)進行通訊的具體實現(xiàn),需要的朋友可以參考下
js 與 php 通過json數(shù)據(jù)進行通訊
例子:
php文件
<?php
echo json_encode(array(array(
'liaotiantiao'=>$liaotiantiao,
'liaotiank'=>$liaotiank,
'chatuserid'=>$chatuserid,
'chattouserid'=>$chattouserid
)));
?>
html 文件
$(document).ready(function(){
//默認條聊天條聊天框狀態(tài)
$.post('/index.php/chat/morenltt',{},function(val){
var obj=eval(val);
alert(obj[0].chatuserid);
});
});
例子:
php文件
復制代碼 代碼如下:
<?php
echo json_encode(array(array(
'liaotiantiao'=>$liaotiantiao,
'liaotiank'=>$liaotiank,
'chatuserid'=>$chatuserid,
'chattouserid'=>$chattouserid
)));
?>
html 文件
復制代碼 代碼如下:
$(document).ready(function(){
//默認條聊天條聊天框狀態(tài)
$.post('/index.php/chat/morenltt',{},function(val){
var obj=eval(val);
alert(obj[0].chatuserid);
});
});
相關(guān)文章
JS簡單獲取當前日期時間的方法(如:2017-03-29 11:41:10 星期四)
這篇文章主要介紹了JS簡單獲取當前日期時間的方法,涉及javascript針對當前日期時間的簡單運算操作,需要的朋友可以參考下2017-03-03
輕松實現(xiàn)HTML和JS之間的轉(zhuǎn)化的代碼
輕松實現(xiàn)HTML和JS之間的轉(zhuǎn)化的代碼...2007-09-09

