Home  >  Article  >  Backend Development  >  php 怎么响应button的onclick事件

php 怎么响应button的onclick事件

WBOY
WBOYOriginal
2016-06-23 14:01:032919browse

我php用的codeigniter框架引用的smart模板,页面上的button事件控制器怎么响应 求高手解答,谢谢。能给个例子最好。


回复讨论(解决方案)

用 JS  异步请求PHP 

能具体点给个例子吗

百度ajax同步异步交互技术

w3school上面搜jquery ajax例子就ok了

index.html 按钮及js执行事件

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head>  <meta http-equiv="content-type" content="text/html;charset=utf-8">  <title> button click test </title>  <script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/jquery/1.10.0/jquery.min.js"></script>  <script type="text/javascript">  function getdata(){	$.ajax({		url: "do.php",  // 这里改成你要执行的php便可		success: function(data){			if(data.success==1){ // 根据返回的数据做不同处理				alert(data.msg);			}		}	});  }  </script> </head> <body>  <input type="button" onclick="getdata()" value="执行php"> </body></html>


do.php 要执行的php,根据需要写不同内容便可。
<?php$ret = array();$ret['success'] = 1;$ret['msg'] = '调用php成功';header('content-type:application/json');echo json_encode($ret);?>

下面是我的文件目录以及的我代码 调试报错为127.0.0:8088/teamlogging/application/controllers/Login.php不允许访问,这是为什么啊

127.0.0:8088

这个是手误么?

这个是我apache的端口号

是手误原本是127.0.0.1:8088

127.0.0.1:8088/teamlogging/application/controllers/Login.php/LoginActive?username=005&password=wl
报错为这个 403  不允许访问

127.0.0.1 :8088还是手误吗 这个冒号

程序里面的地址是对的上面的是我手写出错的
我觉得应该是路径的问题,不允许访问应该是权限的问题,codeigniter不知道有没有什么权限。

是不是我的路径不应该这样写?   刚才我在views文件夹里面又加了几个html页面
例如a.html,b.html,c.html
在a.html里面引用b.html,和c.html也报同样的错误不允许访问
引用的路径为src="application/views/b.html"
src="application/views/c.html"

有没有高手来帮下忙的 分不够可以加啊

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