php $ajax

回首过往如一梦 2017-07-19 03:08:39
点击刷新按钮 刷新div中的内容但是只有Access denied 浏览器f12 http响应码为200 显示文件已成功处理 但是response却显示Access denied
...全文
152 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复
引用 7 楼 xuzuning 的回复:
把 contentType:'application/x-www-form-urlencoded', 去掉
去掉 结果也一样
xuzuning 2017-07-20
  • 打赏
  • 举报
回复
把 contentType:'application/x-www-form-urlencoded', 去掉
  • 打赏
  • 举报
回复
引用 5 楼 xuzuning 的回复:
Access denied 拒绝访问 确认 http://demo.osadmin.org:9096/uploads/ajax/refresh.php 没有跨域
是不是权限问题
xuzuning 2017-07-20
  • 打赏
  • 举报
回复
Access denied 拒绝访问 确认 http://demo.osadmin.org:9096/uploads/ajax/refresh.php 没有跨域
  • 打赏
  • 举报
回复

<?php
		  include('../include/lib/Template.class.php');
		   require ('../include/init.inc.php');

    function cc(){
try{
			$dbh = new PDO('mysql:host=localhost;dbname=osadmin','root','root'); 
			 $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);    
			$dbh->exec('set names utf8'); 

			$stmt = $dbh->prepare('SELECT * FROM char_pie');    
			$stmt->execute();    
            $arr = array();
			while($row = $stmt->fetch(PDO::FETCH_ASSOC))
			{       
			       $arr[]=$row ;
			}   
            return $arr;
		
			$dbh = null;
			}catch(PDOException $e){  
				print"Error!:".$e->getMessage()."<br/>";  
		  
			}  
	}
template::assign('ids',cc());
 ?>
html

<{include file ="header.tpl"}>
<{include file ="navibar.tpl"}>
<{include file ="sidebar.tpl"}>

<!--- START 以上内容不需更改,保证该TPL页内的标签匹配即可 --->

<{$osadmin_action_alert}>
<{$osadmin_quick_note}>

   <div >
   <input  style="margin-left:95.8%;margin-top:10px;" type="submit" value="刷新" >
   </div>
    
    <div class="block">
        <a href="#page-stats" class="block-heading" data-toggle="collapse">当前信息</a> 
          <div id="page-stats" class="block-body collapse in">
               <table class="table table-striped">      
                               <tr>
                                <td>编号</td>
                                <td>搜素引擎</td>
                                <td>点击次数</td>
                              </tr>
                           <{foreach $ids as $list}>
                              <tr>
                                <td ><{$list.id}></td>
                                <td ><{$list.title}></td>
                                <td ><{$list.pv}></td>
                              </tr>
                              <{/foreach}>
                          </table>
        </div>
        </div>
    
    <script  scr="../assets/lib/jquery-1.8.1.min.js"></script>
    <script >
     $('input').click(function(){
      $.ajax({
        url:'http://demo.osadmin.org:9096/uploads/ajax/refresh.php',
        type:'get',
        contentType:'application/x-www-form-urlencoded',
        success:function(data){
        $('#page-stats').html(data);
        }
      })
    })
</script> 

<!--- END 以下内容不需更改,请保证该TPL页内的标签匹配即可 --->
<{include file="footer.tpl"}>
一起混吧 2017-07-20
  • 打赏
  • 举报
回复
贴出代码以供分析 另外,直接访问php文件有问题吗?
hongmei85 2017-07-19
  • 打赏
  • 举报
回复
http响应码为200 也有可能是那接口拒绝了你的请求
游北亮 2017-07-19
  • 打赏
  • 举报
回复
安装一个Fiddler 抓包看看请求的url,以及返回的数据到底是啥

21,886

社区成员

发帖
与我相关
我的任务
社区描述
从PHP安装配置,PHP入门,PHP基础到PHP应用
社区管理员
  • 基础编程社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧