Home > Web Front-end > JS Tutorial > body text

Example of communication between js and php through json data_javascript skills

WBOY
Release: 2016-05-16 16:54:25
Original
1092 people have browsed it

js and php communicate through json data

Example:

php file

Copy code The code is as follows:

echo json_encode(array(array(
'liaotiantiao'=>$liaotiantiao,
'liaotiantiao'=>$liaotiantiao,
'chatuserid'=>$chatuserid,
'chattouserid'=>$chattouserid
)));


Copy code
The code is as follows: $(document).ready(function(){ / /Default chat box status$.post('/index.php/chat/morenltt',{},function(val){
var obj=eval(val);
alert( obj[0].chatuserid);
});
});

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!