Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7534357
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T05:59:29+00:00 2026-05-30T05:59:29+00:00

I am firing a GET request with Greasemonkey’s GM_xmlhttpRequest() : $(.getReview).click(function(){ var videoId =

  • 0

I am firing a GET request with Greasemonkey’s 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);
      }
    }); 

and here is the server code ytube.php:

<?php
  print_r($_REQUEST);
  print_r($_GET);
  echo "Hello friends".$_GET['vid'];
?>

$_REQUEST => returns some data related to WordPress.
$_GET => returns a blank array.

I can’t figure out what’s wrong. I even tried the POST method too.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T05:59:31+00:00Added an answer on May 30, 2026 at 5:59 am

    The data parameter only works for POST methods. If you wish to send data with a GET request, append it to the URL:

    GM_xmlhttpRequest ( {
        method: "GET",
        url:    "http://www.amitpatil.me/demos/ytube.php?username=johndoe&password=xyz123",
        // Use no data: argument with a GET request.
        ... ...
    } ); 
    

    But it’s better to send data via POST, for a variety of reasons. To do that, you need to specify an encoding:

    GM_xmlhttpRequest ( {
        method: "POST",
        url:    "http://www.amitpatil.me/demos/ytube.php",
        data:   "username=johndoe&password=xyz123",
        headers: {
            "Content-Type": "application/x-www-form-urlencoded",
            "User-Agent": "Mozilla/5.0",    // If not specified, navigator.userAgent will be used.
            "Accept": "text/xml"            // If not specified, browser defaults will be used.
        }, 
        ... ...
    } ); 
    


    If you are going to send a lot of data, or complex data, use JSON:

    var ajaxDataObj = {
        u: username,
        p: password,
        vidInfo: [123, "LOLcats Terrorize City!", "Five stars"]
    };
    
    var serializedData  = JSON.stringify (ajaxDataObj);
    
    GM_xmlhttpRequest ( {
        method: "POST",
        url:    "http://www.amitpatil.me/demos/ytube.php",
        data:   serializedData,
        headers: {
            "Content-Type": "application/json",
            "User-Agent": "Mozilla/5.0",    // If not specified, navigator.userAgent will be used.
            "Accept": "text/xml"            // If not specified, browser defaults will be used.
        }, 
        ... ...
    } ); 
    

    Your PHP would access it like so:

    $jsonData   = json_decode($HTTP_RAW_POST_DATA);
    

    Update:
    Greasemonkey and Tampermonkey now require that you set @grant GM_xmlhttpRequest in the metadata block. Be sure to do that.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

While trying to GET a JSON, my callback function is NOT firing. $.ajax({ type:GET,
If a GET request is made as follows $(window).bind('beforeunload', function() { // GET request
I cannot figure out why this Ajax request is not firing correctly. For simplicity's
Before you start firing at me, I'm NOT looking to do this, but someone
DataGridView.CellContentClick is not firing if I mouse click a DataGridViewCheckBoxCell very fast. How can
I am firing an Ajax request using jQuery. During the process, I show a
I'm trying to modify my GreaseMonkey script from firing on window.onload to window.DOMContentLoaded, but
I have the following function: function validateField(query) { new Request.JSON({ onRequest : function() {
Bit of a JavaScript newbie here - I am firing this basic bit of
(I also posted this as an issue on request's github page - link )

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.