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

  • Home
  • SEARCH
  • 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 7079101
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:37:47+00:00 2026-05-28T06:37:47+00:00

So I wrote an ajax call to github using dataType: json, which worked on

  • 0

So I wrote an ajax call to github using dataType: json, which worked on my local machine, but it appears that I need to use dataType: jsonP to deal with the cross domain issues. So can anyone help me make the necessary changes. (BTW github appears to support jsonp dataTypes – https://github.com/pgxn/pgxn-api/wiki/JSONP)

$.ajax({
    url: "https://api.github.com/repos/jeffreycwitt/prollecture1/tags",
    dataType: "jsonp",
    crossDomain: true,
    success: function(returndata) {
        if (returndata.length === 0) {
            $("#versionBox").remove();
        }
        else if (returndata.length === 1) {
            $("#versionBox").remove();
        }
        else {
            $.each(returndata, function() {
                $("#versionBox").show();
                var tag = this["name"];
                console.log(tag);
                var currentVersion = $("#editionNumber").text();
                if (tag.substring(1) === currentVersion) {
                    tag = tag + " (Current Version)";
                }
                var linkname = "textdisplay.php?flag=<?php echo $fs; ?>&ed=" + tag;
                $('#versionSubBox').append("<p><a href='" + linkname + "'>View Version: " + tag + "</a></p>");
            });

        }
    }
});

Like i said, this was working when I was just using dataType, json, but its not working with jsonP. I’m under the impressions github will send back the regular json wrapped in something named by the callback parameter added to the call ?callback=?. (This parameter is added automatically by jquery when the dataType is changed to jsonp. So do I need to somehow modify my success function to parse through the wrapper?

  • 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-28T06:37:48+00:00Added an answer on May 28, 2026 at 6:37 am

    Your code seems to work as seen in this live demo.

    The problem you are having is that you are trying to access a .length property on the
    returndata object and such property doesn’t exist:

    {
        "data": [
            {
                "tarball_url": "https://github.com/jeffreycwitt/prollecture1/tarball/v0.2",
                "commit": {
                    "sha": "46a8aea57cd095a603f194f83cd4a18adcb35908",
                    "url": "https://api.github.com/repos/jeffreycwitt/prollecture1/commits/46a8aea57cd095a603f194f83cd4a18adcb35908"
                },
                "name": "v0.2",
                "zipball_url": "https://github.com/jeffreycwitt/prollecture1/zipball/v0.2"
            }
        ],
        "meta": {
            "status": 200,
            "X-RateLimit-Limit": "5000",
            "X-RateLimit-Remaining": "4993"
        }
    }
    

    I guess you meant returndata.data.length because you have a data property which is an array.

    So:

    var data = returndata.data;
    if (data.length === 0) {
        $("#versionBox").remove();
    }
    else if (data.length === 1) {
        $("#versionBox").remove();
    }
    else {
        $.each(data, function() {
            $("#versionBox").show();
            var tag = this["name"];
            console.log(tag);
            var currentVersion = $("#editionNumber").text();
            if (tag.substring(1) === currentVersion) {
                tag = tag + " (Current Version)";
            }
            var linkname = "textdisplay.php?flag=<?php echo $fs; ?>&ed=" + tag;
            $('#versionSubBox').append("<p><a href='" + linkname + "'>View Version: " + tag + "</a></p>");
        });
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have pretty much the same Ajax Request call but I need to expand
in first ajax call server returns a json string that is converted to js
I need to write a sophisticated website that does AJax, drag and drop, component
I'm trying to write a custom servlet (for AJAX/JSON) in which I would like
In jQuery I wrote this simple ajax call to convert from one currency to
I'm using an ajax call to do a minor calculation then return the value
what is the correct way to determine that an AJAX call is successful? I
I have an AJAX call that I want to run against a WCF GET
I am requesting with AJAX (using jQuery) a tag which contains a Javascript function
Hey guys, I'm doing an AJAX POST call - but with FireBug you can

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.