php脚本在Chrome上的表现与IE& amp;相反FF [英] Php script performing differently on Chrome as oppose to IE & FF

查看:113
本文介绍了php脚本在Chrome上的表现与IE& amp;相反FF的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个php脚本,可从tumblr返回帖子.职位由数字确定.每当我在网站上按执行"按钮时,数字就会增加1.这似乎可以在Firefox和Internet Explorer中完美运行,但不适用于chrome.

如果您在Chrome中多次点击执行"按钮,您会发现它会恢复为0.如果您非常快速地反复单击该按钮,它将起作用.

我的代码:

我的index.php文件.

I have a php script that returns posts from tumblr. The posts are determined by a number. The number is incremented by 1 every time I hit the go button on my website. This seems to work perfectly in Firefox and Internet explorer but not chrome.

If you hit the ''Go'' button a few times in chrome you will notice it will revert back to 0. If you click button repeatedly really fast, it will work.

My code:

My index.php file.

<?php

     session_start();

     $_SESSION['views'] = 0;

 ?>
 <?php include 'blogFunction.php';?>

 <script type="text/javascript">
 function doSomething()
 {
    $.ajax({ url: '/blogFunction.php',
     data: {action: 'test'},
     type: 'post',
     success: function(output) {
     document.getElementById("blog").innerHTML = '';
              document.getElementById("blog").innerHTML = output;
                 }
   });
  }
 </script>

 <div class ="blog" id = "blog"></div>




我的blogFunction.php





my blogFunction.php


function blogreturn(){
    $request_url = "http://retrovate.tumblr.com/api/read?type=posts";
    $xml = simplexml_load_file($request_url);


    $a = $_SESSION['views'];
    $b = $a+4;
    echo "A = ".$a;
    echo "B = ".$b;
    $_SESSION['views'] = $_SESSION['views']+ 1;
    for ($i = $a; $i <= $b; $i=$i+1) {
            echo '<h2>'.$xml->posts->post[$i]->{'regular-title'}.'</h2>';
            echo '<br>';
            echo $xml->posts->post[$i]->{'regular-body'};
            echo '<br>';
            echo '<br>';
    }
}




可以在此处找到我的网站进行测试.

该网站还应在开始"按钮下打印A和B的值.

我已与朋友确认该问题仍然存在于chrome上,而不是其他任何浏览器上.

知道为什么它在chrome中不起作用.




My website can be found here to test.

The website should also print the values of A and B under the ''Go'' Button.

I have confirmed with friends that the problem persists on chrome and not any other browser.

Any idea why it doesn''t work in chrome. Thanks in advance!

推荐答案

_SESSION ['views'] 0; ? > <? php 包括 'blogFunction.php';? > < 脚本 =" 文本/javascript"
_SESSION['views'] = 0; ?> <?php include 'blogFunction.php';?> <script type="text/javascript"> function doSomething() {


.ajax({url:'/blogFunction.php', 数据:{action:'test'}, 类型:"post", 成功:功能(输出){ document.getElementById("blog").innerHTML =''; document.getElementById("blog").innerHTML =输出; } }); } < /script > < div 博客" id =" > < /div >
.ajax({ url: '/blogFunction.php', data: {action: 'test'}, type: 'post', success: function(output) { document.getElementById("blog").innerHTML = ''; document.getElementById("blog").innerHTML = output; } }); } </script> <div class ="blog" id = "blog"></div>




我的blogFunction.php





my blogFunction.php


function blogreturn(){
    


request_url = " ;
request_url = "http://retrovate.tumblr.com/api/read?type=posts";


这篇关于php脚本在Chrome上的表现与IE&amp; amp;相反FF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆