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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T10:49:51+00:00 2026-05-30T10:49:51+00:00

I am a newbie to Jquery. I am trying to send a request with

  • 0

I am a newbie to Jquery.
I am trying to send a request with basic authentication using jquery. This is what i do.

$.ajax({
          type: "GET",
          url: domain,
          dataType: 'json',
          success: function(){
            alert('Thanks for your comment!'); 
          },
          error:function(){
            alert('here');
          },
          beforeSend: function(xhr){ 
            xhr.setRequestHeader('Authorization', 'Basic ' + encodeBase64(username + ":" + password));
          }
});

But my problem is I dont get any feedack. Looks like both the success or the error method is called.

On further debugging i get

Uncaught ReferenceError: encodeBase64 is not defined

What am i missing? Help would be appreciated.

  • 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-30T10:49:53+00:00Added an answer on May 30, 2026 at 10:49 am

    The error is saying that there is no method called encodeBase64 defined.

    Many browsers have a built-in conversion from ascii to base64 called btoa:

    xhr.setRequestHeader('Authorization', 'Basic ' + btoa(username + ":" + password));
    

    If you are supporting older browsers, make sure that there is a base64 polyfill, such as the one at http://ww.w.icodesnip.com/search/javascript%20dark%20codes/45

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

Sidebar

Related Questions

I'm a newbie with jQuery and I'm trying to figure out this slideToggle function.
I'm trying to figure out why this is a problem when using jQuery 1.4.2
Hello I am a newbie working with jQuery and Ajax. I am trying submit
I'm trying to get the values from multiple textboxes using JQuery. I'm a bit
I am newbie to jQuery , just trying to learn it since last couple
I'm a jQuery newbie as of this morning, and this is the code I've
I am newbie to jQuery, can someone explain what this code does: $(#currency form).submit(function(e)
I am a newbie to Jquery so apoligise if this is a silly question
Im still somewhat of a newbie on jQuery and the ajax scene, but I
I am using jquery(newbie for jquery) in my application. In short what I am

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.