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

  • SEARCH
  • Home
  • 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 9021609
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T05:17:43+00:00 2026-06-16T05:17:43+00:00

What I am trying to do is run a GET request in javascript when

  • 0

What I am trying to do is run a GET request in javascript when a download link is pressed. When the link is pressed it would send a GET request to a php script that basically counts how many times the link is pressed. Here is my code but I can’t seem to get it to work right. I’m pretty new to javascript but still know my way around. I have tested and My getrulvars() function works and my function when a link is pressed works so I am sure that its my GET request that it not working

function getUrlVars() {
    var vars = {};
    var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m, key, value) {
        vars[key] = value;
    });
    return vars;
}
// Wait for page to load
window.onload = function() {
    var a = document.getElementById("downloadLink");
    var app = getUrlVars()["app"];

    a.onclick = function() {    
        var xmlhttp;
        if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari
            xmlhttp = new XMLHttpRequest();
        } else { // code for IE6, IE5
            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        }
        xmlhttp.open("GET", "download_count.php?app=" + app, true);
        xmlhttp.send();
        return true;
    }
}
  • 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-06-16T05:17:44+00:00Added an answer on June 16, 2026 at 5:17 am

    So I got it working what I had to do is return false then in my php script have it download the file. I guess when I was downloading the file it wouldn’t allow the jQuery to send the GET value.

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

Sidebar

Related Questions

I'm trying to get PhantomJS to run via PHP. When I run the JavaScript
I get the following error from the SQL Script I am trying to run:
I've been trying to get user input from a Javascript prompt into a PHP
I'm trying to run a pull request from git using PHP's exec on windows
When trying to run a junit test I get the following error - java.lang.ClassCastException:
I get the error below when trying to run an executable jar file. The
I get the following error when trying to run my application. There are no
I'm trying to run a java (jnlp) applet from bash and get the PID
I'm trying to run the following code, but get an error in the gameLoop
im trying to get the funnelweb blog application to run on my machine, ive

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.