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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T22:49:06+00:00 2026-06-11T22:49:06+00:00

I have a single page js app and I’m sending custom headers to my

  • 0

I have a single page js app and I’m sending custom headers to my server containing logs, but i need to control the size of those headers because my server won’t accept requests larger then 8k.

My solution thus far was to intercept all outgoing ajax request from my application.

I’m using jQuery Global Ajax Events, particularly ajaxSend to intercept all requests. I cannot use beforeSend because that is a local event.

I can’t seem to access the request headers in the callback. I need to read all request’s header and cut down the logs header if it’s too large.

  • 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-11T22:49:07+00:00Added an answer on June 11, 2026 at 10:49 pm

    You want to use beforeSend to modify the request before it is being sent. This is all covered in the documentation you’ve linked to.

    The global ajaxSend event will not help you tamper with the request. The closest thing to global you can get would be to is call ajaxSetup, passing a beforeSend option to be default for all subsequent ajax calls.


    There appears to be no simple way of getting request headers from an XMLHttpRequest object. Since I assume you’re setting your logging headers yourself, however, you might be able to hook into the setting of these headers, and store an accessible reference to them:

    XMLHttpRequest.prototype.readableHeaders = {};
    XMLHttpRequest.prototype.proxiedSetRequestHeader = XMLHttpRequest.prototype.setRequestHeader;
    XMLHttpRequest.prototype.setRequestHeader = function(header, value) {
        this.proxiedSetRequestHeader(header, value);
        this.readableHeaders[header] = value;
    };
    

    In this manner, you should be able to directly inspect the jqXHR.readableHeaders object for your specific logging header, in beforeSend, and call setRequestHeader once more, to truncate the string, if needed.

    To retrieve the headers you need access to the underlying instance of XMLHttpRequest from jqXHR object. Use xhr() function to retrieve the instance.

    $.ajaxSetup({
      beforeSend: function (jqXHR, settings) {
        console.log( settings.xhr().readableHeaders );
      }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have A single page that has the following structure <form runat=server><placeholder></placeholder></form> I have
I have a nested user control which appears on every single page. It contains
I have a single page jQuery Mobile app with four data-role='pages' in place; so,
I have an ASP.NET 3.5sp1 app that is a single page design. The site
I have a single page app (Rails + Backbone.js + Postgres on Heroku), and
I have a single page web app that shows real time data using just
I have a problem when developing a single page web app. When jQuery send
I have a single page app which has scrolling DIVs as part of the
I have a single-page app that uses a lot of CSS3 shadows. The app
I have a single page app that integrates with other services such as Dropbox

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.