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 8462443
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T14:10:04+00:00 2026-06-10T14:10:04+00:00

I am trying to do an ajax request $.ajax({ type: post, url: download.php, error:

  • 0

I am trying to do an ajax request

$.ajax({
  type: "post",
  url: "download.php",
  error: function(data, status, err){
           alert(JSON.stringify(data));
         },
  data: "fileid="+fileid
});

this request alerts “{“readyState”:0,”responseText”:””,”status”:0,”statusText”:”error”}”

I have searched on google all i have come up with is a cross site ajax call(which this is obviously not)

I have tried putting the full url in and it does the same thing.

the only thing i can think of is the header and i don’t know what would be wrong with it. Here is the request header from firebug

Host                www.mydomain.com
User-Agent          Mozilla/5.0 (Windows NT 6.1; rv:5.0) Gecko/20100101 Firefox/5.0
Accept              */*
Accept-Language     en-us,en;q=0.5
Accept-Encoding     gzip, deflate
Accept-Charset      ISO-8859-1,utf-8;q=0.7,*;q=0.7
Connection          keep-alive
Content-Type        application/x-www-form-urlencoded; charset=UTF-8
X-Requested-With    XMLHttpRequest
Referer             http://www.mydomain.com/
Content-Length      8
Cookie              PHPSESSID=27b7d3890b82345a4fc9604808acd928

I have added another request on a different page and it works just fine but this one keeps failing the header for the other request is:

Host                www.mydomain.com
User-Agent          Mozilla/5.0 (Windows NT 6.1; rv:5.0) Gecko/20100101 Firefox/5.0
Accept              text/plain, */*; q=0.01
Accept-Language     en-us,en;q=0.5
Accept-Encoding     gzip, deflate
Accept-Charset      ISO-8859-1,utf-8;q=0.7,*;q=0.7
Connection          keep-alive
Content-Type        application/x-www-form-urlencoded; charset=UTF-8
X-Requested-With    XMLHttpRequest
Referer             http://www.mydomain.com/differentpage.php
Content-Length      33
Cookie              PHPSESSID=27b7d3890b82345a4fc9604808acd928
  • 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-10T14:10:05+00:00Added an answer on June 10, 2026 at 2:10 pm

    I came across the same issue: how to register every time a user click the link.

    The problem is infact that if you don’t stop the pop up, the ajax request doesn’t complete and you get readyState: 0!

    I’ve done another version of the above that maybe is more readable (even if more verbose)

    /*  --------------------------------------------------------------------------
     *  Before that add 'downloads' class to every anchor tag (link) in your page
     *  This script does the rest
     *  
     *  remember to change 'your_php_file' with the one you use
     *  -------------------------------------------------------------------------- */
    
    $(document).ready( function()
    {
    
        // Check if there is any link with class 'downloads'
        if ( typeof $('.downloads') != 'undefined' )
        {
            var links = $('.downloads');
    
            // Run this for every download link
            for ( var i = 0; i < links.length; i++ )
            {   
                // Set click behaviour
                links[i].onclick = function(e)
                {
                    // Get download name
                    var attr = this.attributes,
                        href = attr.href.textContent,
                        elem = href.split('/'),
                        elem = elem[elem.length - 1];
    
                    // Send the download file name and only after completing the request let the user download the file
                    $.ajax(
                    {
                        type : "POST",
                        dataType : "text",
                        // 'your_php_file' must be an ABSOLUT or RELATIVE path!
                        url: your_php_file,
                        // 'elem' is a variable containing the download name
                        // you can call it in your php file through $_POST['download_name']
                        data: { download_name: elem },
                        // here we go magic:
                        // after the request is done run the popup for the download
                        complete: function()
                        {
                            window.location.href = href;
                        }
                    });
    
                    // Stop default behaviour until ajax request has been done
                    e.preventDefault();
                };
            }
        }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to send a json RPC ajax request when the page is
I was trying to send an ajax request as POST request. But when i
I'm making an AJAX request and sending along some JSON: $(function() { var json
I'm trying to make a post request via ajax using jQuery (for the BaseCamp
i am trying to return value from ajax request to a function on form
i am trying to alert the return value captured by the ajax request. The
I have some jQuery that looks like this: $.ajax({ type: POST, url: /Customer/CancelSubscription/<%= Model.Customer.Id
I'm trying to send a JSON object from an AJAX request to my server.
I'm trying to fire an Ajax request with some data being returned by a
I'm trying to use an ajax request to call a function in a different

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.