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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T00:22:04+00:00 2026-06-01T00:22:04+00:00

I have an AJAX call getting info out of the Github API. It is

  • 0

I have an AJAX call getting info out of the Github API. It is returned in base64 encoding but when i try to decode it I get the aforementioned error.

Has anyone run into this before and know what is going on? The info the server is returning runs fine through web based decoders. Maybe it get s mangled a bit in a variable? IDK :/

(function () {
    'use strict';

    var objectsList = [];
    var isParsing = 0;
    var insertArea = $('body');

    function makeAJAXCall(hash, cb) {
        $.ajaxSetup({
            Accept: 'Application/vnd.github.raw+json',
            dataType: 'jsonp'
        });

        $.ajax({
            url: hash,
            success: function (json) {
                if (cb) {
                    cb(json);
                }
            },
            error: function (error) {
                console.error(error);
                throw error;
            }
        });
    }

    function parseBlob(hash, cb) {
        makeAJAXCall(hash, function (returnedJSON) {  // no loop as only one entry
            if (cb) {
                cb(returnedJSON.data.content);
            }
        });
    }

    function addSVGToPage(SVGToAdd) {
        var entry, decodedEntry;
        makeAJAXCall(SVGToAdd, function (returnedJSON) {
            console.info(window.atob(returnedJSON.data.content));
        });
    }

    function parseTree(hash) {
        var i, entry;
        var tree = 'https://api.github.com/repos/myusername/SVG-Shapes/git/trees/' + hash;

        makeAJAXCall(tree, function (returnedJSON) {
            for (i = 0;  i < returnedJSON.data.tree.length; i += 1) {
                entry = returnedJSON.data.tree[i];

                if (entry.type === 'blob') {
                    if (entry.path.slice(-4) === '.svg') {     // we only want the svg images not the ignore file and README etc
                        addSVGToPage(entry.url);
                    }
                } else if (entry.type === 'tree') {
                    parseTree(entry.sha);
                }
            }
        });
    }

    $(document).ready(function () {
        parseTree('master');
    });
}());

Edit: below is a sample of what is returned from a console.info(returnedJSON.data.content);

PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4KPCFET0NU WVBFIHN2ZyBQVUJMSUMgIi0vL1czQy8vRFREIFNWRyAxLjEvL0VOIiAiaHR0 cDovL3d3dy53My5vcmcvR3JhcGhpY3MvU1ZHLzEuMS9EVEQvc3ZnMTEuZHRk Ij4KPHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHht bG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB2ZXJz aW9uPSIxLjEiIGhlaWdodD0iMjQiIHdpZHRoPSI0MDAiPgkKCTxkZWZzPgoJ CTxwYXR0ZXJuIGlkPSJzdHJpcGVkYmFjayIgaGVpZ2h0PSIyMCIgd2lkdGg9 IjIwIiB5PSIyIiBwYXR0ZXJuVW5pdHM9InVzZXJTcGFjZU9uVXNlIiBvdmVy Zmxvdz0ic2Nyb2xsIj4KCQkJPGcgdHJhbnNmb3JtPSJza2V3WCgtMjApIj4K CQkJCTxyZWN0IHg9Ii0xMCIgeT0iMCIgd2lkdGg9IjEwIiBoZWlnaHQ9IjIw IiBzdHJva2U9Im5vbmUiIGZpbGw9IiNGMkYy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bGF0ZSIKCQkJCWZyb209 IjIwIiB0bz0iMCIKCQkJCWJlZ2luPSIwcyIgZHVyPSIwLjZzIgoJCQkJcmVw ZWF0Q291bnQ9ImluZGVmaW5pdGUiCgkJCQlhZGRpdGl2ZT0ic3VtIi8+CgkJ PC9yZWN0PgoJPC9nPgo8L3N2Zz4K
  • 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-01T00:22:05+00:00Added an answer on June 1, 2026 at 12:22 am

    atob breaks due to the newlines in the response. Remove them to get your code to work:

    function addSVGToPage(SVGToAdd) {
        var entry, decodedEntry;         // <-- What is this doing here? It's unused.
        makeAJAXCall(SVGToAdd, function (returnedJSON) {
            console.info(window.atob(returnedJSON.data.content.replace(/\s/g, '')));
            //                                                ^^^^^^^^^^^^^^^^^^^
        });
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jQuery AJAX call with type:'GET' like this: $.ajax({type:'GET',url:'/createUser',data:userId=12345&userName=test, success:function(data){ alert('successful'); }
I have ajax code for asp.net (non-mvc) to call to a webMethod to get
I'm have trouble grabbing the response JSON data that's returned via AJAX call. Here
So I have my JavaScript making an Ajax call to /my_controller/ajax_action but then in
i have an ajax call $.ajax({ url: '<%=Url.Action(SaveDetails,Survey) %>', dataType: 'JSON', cache: false, data:
If I have an ajax call off fetching (with a callback) and then some
I am running ASP.NET MVC Beta. I have an AJAX call running through jQuery
I have an $.ajax call that includes both a success and error condition: $('input[name=StateName]').live('change',
A situation I ran across this week: we have a jQuery Ajax call that
The problem is the following. We have lots of ajax call via $.ajax function.

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.