js 与 php 通过json数据进行通讯示例
时间:2021-04-11 08:58:04|栏目:JavaScript代码|点击: 次
js 与 php 通过json数据进行通讯
例子:
php文件
<?php
echo json_encode(array(array(
'liaotiantiao'=>$liaotiantiao,
'liaotiank'=>$liaotiank,
'chatuserid'=>$chatuserid,
'chattouserid'=>$chattouserid
)));
?>
html 文件
$(document).ready(function(){
//默认条聊天条聊天框状态
$.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(){
//默认条聊天条聊天框状态
$.post('/index.php/chat/morenltt',{},function(val){
var obj=eval(val);
alert(obj[0].chatuserid);
});
});
上一篇:JS实现超简单的鼠标拖动效果
栏 目:JavaScript代码
下一篇:Open and Print a Word Document
本文地址:http://www.codeinn.net/misctech/99198.html






