<br /><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><br /><html><br /> <head><br /> <meta http-equiv="content-type" content="text/html;charset=utf-8"><br /> <title> button click test </title><br /> <script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/jquery/1.10.0/jquery.min.js"></script><br /> <script type="text/javascript"><br /> function getdata(){<br /> $.ajax({<br /> url: "do.php", // 这里改成你要执行的php便可<br /> success: function(data){<br /> if(data.success==1){ // 根据返回的数据做不同处理<br /> alert(data.msg);<br /> }<br /> }<br /> });<br /> }<br /> </script><br /> </head><br /><br /> <body><br /> <input type="button" onclick="getdata()" value="执行php"><br /> </body><br /></html><br /><br /><?php<br />$ret = array();<br />$ret['success'] = 1;<br />$ret['msg'] = '调用php成功';<br />header('content-type:application/json');<br />echo json_encode($ret);<br />?><br />
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号