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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T14:58:28+00:00 2026-05-22T14:58:28+00:00

Instead of using the beforeSend method of setting the request headers, I decided I

  • 0

Instead of using the beforeSend method of setting the request headers, I decided I wanted to look into using the headers setting option of a jQuery $.ajax() call. Naturally, I went to this page here, http://api.jquery.com/jQuery.ajax/, but the documentation is scarce and I can’t find any way to set multiple headers and the format for doing so on that page, or anywhere else.

@tahir: Then why is this not working?

<!DOCTYPE html>
<html>
  <head>
    <title>Multiple DnD Uploader</title>
    <link rel="stylesheet" href="style.css" />
    <script type = "text/javascript" src = "../music/jquery.js"></script>
    <script type="text/javascript">
      $(document).ready(function(){
        $('#drop').change(function(event){
          files = event.target.files;
          $('#drop').css('display', 'none');
          for(var i = 0, len = files.length; i < len; i++) {
            alert(files[i].fileName);
            $.ajax({
              type: "POST",
              url: "uploader.php",
              contentType: "multipart/form-data",
              headers: {
                "X-File-Name" : ""+files[i].fileName,
                "X-File-Size" : ""+files[i].fileSize
              },
              data: 'hi',
              success: function(data){
                $('#info').append('Success: ' + data + '<br />');
              },error: function(data){
                $('#info').append('Error: ' + data + '<br />');
              }
            });
          }
        });
      });
    </script>
  </head>
  <body>
    <div id="drop">
      <h1>Drop files here</h1>
      <p>To add them as attachments</p>
      <input type="file" multiple="true" id="filesUpload" />
    </div>
    <div id="info">
    </div>
  </body>
</html>

The two X-File-Name and X-File-Size attributes aren’t showing up in the request headers.

SOLUTION: I feel really stupid, turns out the particular jquery.js file I was pointing to was 1.4.4, so I upgraded and now it works! Thanks.

  • 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-22T14:58:29+00:00Added an answer on May 22, 2026 at 2:58 pm

    It says:

    A map of additional header key/value pairs to send along with the request. This setting is set before the beforeSend function is called; therefore, any values in the headers setting can be overwritten from within the beforeSend function.

    So all you have to do is to pass an object like:

    {"header1":"value1","header2":"value2"}
    

    and so on. Here is some code that adds Accept header in a post request:

        $.ajax("relative/url/action.do",{
        success: function(){
            alert("success");
        },
        error: function(jqXHR, textStatus, errorThrown){
            alert(textStatus + ": " + jqXHR.responseText );
        },
        headers: {Accept: "application/json"},
        type : "POST"
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to pass request headers in an AJAX GET using jQuery. In
I am using jQuery with ASP.NET in a project. Instead of using ASP.NET Ajax,
I'm using buttons to submit data via Ajax. I'm using jQuery to disable and
Instead using the google search appliance crawler for index content, im using a query
...instead of using the Atom syndication format? Atom is a well-defined , general-purpose XML
Instead of using $this->fetchAll('email = ?',$email)->current() inside the model class, is there a way
Instead of using an interface like this: public interface IStartable { void Start(); void
Instead of using an external web-based Mercurial host, I want to set one up
instead of using getParameterByName('Field', PostData) (PostData == $('form').serialize();) I would like to write PostData.Field,
When I use conditional breakpoint in VS2005 instead of using temporary code to check

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.