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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T23:17:06+00:00 2026-06-01T23:17:06+00:00

I have looked at the following questions here on stackoverflow with no luck in

  • 0

I have looked at the following questions here on stackoverflow with no luck in what im trying to do.

Ajax Authorization Request headers fails again and again

jQuery Ajax Unauthorized 401 Error

Sending credentials with cross-domain posts?

Here is my code that I currently have:

    $(document).ready(function() {
        $.ajax({
            url: 'http://sample.domain.com/script.php?name1=value1&jsonp=?',
            type: 'GET',
            dataType: 'json',
            contentType: "application/json",
            beforeSend: function(xhr) {
                 xhr.setRequestHeader("Authentication", "Basic ZnJvbWFwcGx********uOnRoM24zcmQ1UmgzcjM=") //Some characters have been replaced for security but this is a true BASE64 of "username:password"
            },
            success: function(data){
                alert(data);
            }
        });
    });


</script>

The subdomain I have is password protected by an .htpasswd file. The login of the site works just fine for me using the username/password combo used in the base64 encode.

Im running this script on a different domain than the one that the url is on which is why i have the jsonp=? in the url

The response im getting from the console in the browser is:
GET http://sample.domain.com/script.php?name1=value1&jsonp=jsonp1334177732136 401 (Authorization Required)

  • 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-01T23:17:08+00:00Added an answer on June 1, 2026 at 11:17 pm

    JSONP uses a script tag proxy. It wouldn’t support custom headers. Are you in control of the endpoint? If so look into enabling CORS, or pass the authentication key in the GET string.

    When using jsonp JQuery converts your URL “ajax” request to:

    <script src="[endpoint]"></script>
    

    it then writes a random function

    var json9409d0sf0d9s0df90 = function() {
         //some callback logic here.
    }
    

    and appends ?callback=json9409d0sf0d9s0df90

    your server then says

    echo $_GET['callback] . "(" . $json . ")";
    

    and sends that back as the response so

    json9409d0sf0d9s0df90({some: data});
    

    is exexcuted by the browser and handled by jQuery’s magical handlers that make it respond like a normal ajax callback.

    AFAIK, <script src=""></script> asset loads wont take custom headers by any standard browser.

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

Sidebar

Related Questions

I have looked here and from what I understand the following regex simply means
I have looked through the other questions on here, and on other forums. The
I've looked around but have yet to find a great solution the the following
Have looked quite hard for this answer but having no luck. I have 3
I have looked at questions like this , this , this and this ,
I have looked around on Google and StackOverflow for the answer to this question,
I've looked through several other questions here and on other sites regarding this issue,
I've google it and also looked some related questions here in SO, but didn't
I've been trying this for a bit now and have looked at other answers
I have looked around here to see if somebody has asked this question before

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.