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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T01:59:33+00:00 2026-05-17T01:59:33+00:00

The problem is in the difference how browsers implement simple calls. The problem occurs

  • 0

The problem is in the difference how browsers implement simple calls. The problem occurs while using colorbox extenstion (facebox variant). Content is loaded into colorbox with jquery load() function.

When the call is made by Chrome, Accept header is set to:

Accept: text/html, */*, text/javascript

In case of FireFox, header looks like this:

Accept: text/javascript

I tried to force the Accept header by setting it using:

jQuery.ajaxSetup({  
  'beforeSend': function (xhr) {xhr.setRequestHeader("Accept", "text/javascript")}  
}); 

It works well while using $.ajax calls, but it doesn’t seem to affect .load function. Any
idea how to solve this issue?

  • 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-17T01:59:33+00:00Added an answer on May 17, 2026 at 1:59 am

    Even though it’s obviously better to avoid the issue by using the $.ajax call directly, you can create a proxy method for the $.ajax method. This helps since $.load in turn calls $.ajax with a set of default parameters. We can therefore intercept $.loads call to $.ajax.

    var org = $.ajax;
    $.ajax = function(settings){
        settings['accepts'] = null;
        settings['beforeSend'] = function(xhr) {
            xhr.setRequestHeader("Accept", "text/javascript");
        }
        org(settings);
    }
    
     $("#foo").load("http://fiddle.jshell.net/FpCBJ/show/light/");
    

    Try

    Obviously, this will affect ALL calls to $.ajax, so you might want to add another parameter to the proxy method which can be set and checked in the proxy to to avoid setting requestheader when called directly. Or in settings even.

    I guess you could also add/remove the proxy for each call, but this adds overhead and might lead to race conditions(?) (Wouldn’t think so if you remove the proxy straight after the request, don’t wait for callback), so you’d need a lock of some sort.

    EDIT: Added settings['accepts'] = null; to keep $.ajax from adding any headers before the callback as setRequestHeader() only adds, not replaces. Boy this is dirty.

    EDIT 2: Actually, a perhaps cleaner option would be to set up your own accepts and refer to them to allow $.ajax to do its job to map the data types and set up XHR all by itself:

    var org = $.ajax;
    $.ajax = function(settings){
        settings['accepts'] = {"myDataType" : "text/javascript"};
        settings['dataType'] = "myDataType";
        org(settings);
    }
    
     $("#foo").load("http://fiddle.jshell.net/FpCBJ/show/light/");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using Dojo GFX to do some simple drawing, but having a problem with
I have a strange problem working with HTML,CSS in different browsers: Firefox 3.6 and
I've got a problem using different layouts for list items in my project. Here
I've got a problem with textarea's in Google Chrome. I'm using classic ASP, but
I have a fairly simple sync problem. I have a table with about 10
I am trying to implement a custom Java widget using GWT.This requires me to
I am trying to implement a custom Java widget using GWT.This requires me to
I have implemented pretty simple application, using gwt and gwt event service 1.1.1, it
I'm building a calendar in ASP.NET using Jquery, And I'm trying to implement Print.
I'm trying to implement something similar to the iTunes browser, to browser a simple

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.