如何检索其内容已使用jQuery / javascript更改的远程网页?

时间:2015-04-01 03:47:45

标签: php jquery

我这里有2个文件位于不同的主机上。

test1.php

<?php
$curl = curl_init("http://myhost.com/test2.php?tempvar=testonly");
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
$output = curl_exec($curl);
curl_close($curl);

echo $output;
?>

test2.php

<script src="//code.jquery.com/jquery-1.11.1.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
    console.log(getURLParameter("tempvar"));
    //$("#test").html(getURLParameter("tempvar"));

    function getURLParameter(name) {
        return (decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.search.toLowerCase())||[,""])[1].replace(/\+/g, '%20'))).toUpperCase();
    }
});

</script>
<div id="test"><?php echo $_GET['tempvar']; ?> - test</div>

从test2.php中可以看出,我使用PHP echo函数显示URL变量的内容。这工作正常。

我的问题是,当我使用jQuery(在test2.php中)更改页面内容时,curl函数没有获取更新的页面内容。

有关如何解决此问题的任何想法?或者可能是一种解决方法?

我正在使用的页面/代码只是一种实验。因此使用echo函数不是问题。 所涉及的真实网页/代码包括通过jQuery操纵页面内容的代码。

在来到这里之前,我确实搜索了网,却一无所获。我正在尝试使用http_get PHP函数,但遇到服务器问题,我已向服务器团队报告过。

非常感谢。

0 个答案:

没有答案
相关问题