简体   繁体   English

jQuery $()。load从PHP $ _GET中减去信息

[英]Jquery $().load subtracts information from PHP $_GET

I am reloading a <div> with the following JavaScript: 我正在使用以下JavaScript重新加载<div>

$(document).ready(function() {
    $("#commentrefresh").load("commentright.php");
    var refreshId = setInterval(function() {
        $("#commentrefresh").load('commentright.php?randval='+ Math.random());
    }, 9000);
});

At the same time I am including a PHP file eg www.mysite.nl/someotherpage in my main page with: 同时,我在主页中包含一个PHP文件,例如www.mysite.nl/someotherpage,其中包括:

$site = $_GET['site'];
include_once($site);

This is not in the <div> that I want to be refreshed. 我要刷新的不在<div>中。

Both separately work fine, but as soon as I use them both together, the <div> with $site is being refreshed on and on. 两者都可以正常工作,但是一旦我将它们一起使用,带有$site<div>就会不断刷新。 I guess the jQuery request is not specific enough. 我猜想jQuery请求不够具体。 Is there a way to change the script to make sure only the right <div> gets refreshed? 有没有一种方法可以更改脚本以确保仅刷新正确的<div>

Well I've solved the problem myself. 好吧,我自己解决了这个问题。 What happened was that the .htaccess rewrote the server request to www.mysite.nl/index.php?commentright.php.php . 发生的情况是.htaccess将服务器请求重写为www.mysite.nl/index.php?commentright.php.php。

So into the 所以进入

<div id="commentrefresh"> 

the total page appeared. 总页面出现。

I put the line : 我把线:

RewriteRule ^(.*)/commentright.php      /commentright.php 

at the beginning of the rewriterules and now it works properly. 在改写的开始,现在它可以正常工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM