Home > php教程 > php手册 > php+jquery+ajax初体验

php+jquery+ajax初体验

WBOY
Release: 2016-06-21 08:46:20
Original
1038 people have browsed it

这个一个简单的php与ajax案例 仅供新手学习

附上效果图




jquery ajax代码

 $(function(){   $("#send").click(function(){    var cont = $("input").serialize();    $.ajax({     url:'aseoe.php',     type:'post',     dataType:'json',     data:cont,     success:function(data){      var str = data.username + data.age + data.job;      $("#result").html(str);     }    });   });    });
php接收数据

//php ajax 初体验  header("Content-type:text/html;charset=utf-8"); $username = $_POST['username']; $age = $_POST['age']; $job = $_POST['job']; $json_arr = array("username"=>$username,"age"=>$age,"job"=>$job); $json_obj = json_encode($json_arr); echo $json_obj; ?>
更多php+ajax实例,关注爱思资源网



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 Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template