Home >Web Front-end >JS Tutorial >Example of communication between js and php through json data_javascript skills

Example of communication between js and php through json data_javascript skills

WBOY
WBOYOriginal
2016-05-16 16:54:251126browse

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);
});
});

Statement:
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