【发布时间】:2012-03-13 03:32:34
【问题描述】:
我正在使用 Greasemonkey 的 GM_xmlhttpRequest() 发出 GET 请求:
$(".getReview").click(function(){
var videoId = $(this).parents("li").find("a").attr("href");
alert(videoId);
GM_xmlhttpRequest({
method: "GET",
url: "http://www.amitpatil.me/demos/ytube.php",
data: "username=johndoe&password=xyz123",
headers: {
"User-Agent": "Mozilla/5.0", // If not specified, navigator.userAgent will be used.
"Accept": "text/xml" // If not specified, browser defaults will be used.
},
onload: function(response) {
console.log(response);
}
});
这是服务器代码ytube.php:
<?php
print_r($_REQUEST);
print_r($_GET);
echo "Hello friends".$_GET['vid'];
?>
$_REQUEST => 返回一些与 WordPress 相关的数据。
$_GET => 返回一个空白数组。
我不知道出了什么问题。我什至也尝试了POST 方法。
【问题讨论】:
标签: php ajax json greasemonkey tampermonkey