我正在向GET
Greasemonkey 发出请求GM_xmlhttpRequest()
:
$(".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
方法。