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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T14:28:57+00:00 2026-06-08T14:28:57+00:00

I’m trying to make a simple AJAX call to the Justin TV API, which

  • 0

I’m trying to make a simple AJAX call to the Justin TV API, which seems to be failing consistently.

When making the AJAX call with url1, the console reports Object { readyState=4, status=200, statusText="success"}, yet it falls into the error function of the AJAX call. When visiting the URL with my browser, I notice the returned data is [{ ... json ...}].

When making the AJAX call with ‘url’, the call passes, entering the success function. I notice the returned object is { ...json... }.

How do I get a valid JSON object out of the AJAX request for url1?

Here’s a snip of what I’m doing:

var url1 = "http://api.justin.tv/api/stream/list.json"
var url = "https://api.twitch.tv/kraken/streams/";

channelNames = "";
for (channelName in streams)
{
    channelNames = channelNames + ',' + channelName;
}
channelNames = channelNames.slice(1);
console.log(channelNames);
console.log(url1);
$.ajax({
    url: url1,
    type: 'GET',
    crossDomain: true,
    dataType: 'jsonp',
    data: { channel : channelNames },
    success: function(data) 
    {
        console.log(data);
        if(data.streams.length > 0)
        {
            $("#streamStatus").html("<ul class='zebra'>");          
            for(i = 0; i < data.streams.length; i++)
            {
                stream = data.streams[i];
                channel = data.streams[i].channel;
                listItem = "<li id='stream"+i+"'>";
                streamName = "<span class='name'>" + streams[stream.name.slice(10)] + "</span>";
                viewers = "<span class='viewers'>viewers:" + stream.viewers + "</span>";
                gameName = "<div class='game'>" + ((channel.game != null) ? channel.game : "No Game Specified") + "</div>";
                listItem += streamName + viewers + gameName + "</li>"; 
                screenCap = "<div class='screenCap' style='display:none;'>" + channel.screen_cap_url_small + "</div>"
                $("#streamStatus ul.zebra").append(listItem);
                $("#streamStatus ul.zebra").append(screenCap);
                //console.log(channel);
            }
            $("#streamStatus").append("</ul>");
        }
    },
    error: function(data) 
    { 
        console.log(data);
    }

EDIT: Here is the working solution…

var url1 = "http://api.justin.tv/api/stream/list.json"
var url = "https://api.twitch.tv/kraken/streams/";

channelNames = "";
for (channelName in streams)
{
    channelNames = channelNames + ',' + channelName;
}
channelNames = channelNames.slice(1);
console.log(channelNames);
console.log(url1);
$.ajax({
    url: url1,
    type: 'GET',
    crossDomain: true,
    dataType: 'jsonp',
    jsonp: 'jsonp',
    data: { channel : channelNames },
    success: function(data) 
    {
         ...
    },
    error: function(data) 
    { 
        console.log(data);
    }
  • 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-08T14:28:58+00:00Added an answer on June 8, 2026 at 2:28 pm

    You’re passing jsonp as the dataType in the ajax call. They’re not interchangeable.

    As you’ve noted yourself, the data returned from url1 is JSON, not JSONP: JSONP requires wrapping the returned JSON data in a javascript function call.

    A mismatch like this between dataType and the data in the response body will always cause the ajax call to fail.

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

Sidebar

Related Questions

I'm making a simple page using Google Maps API 3. My first. One marker
I am trying to understand how to use SyndicationItem to display feed which is
I'm trying to select an H1 element which is the second-child in its group
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I used javascript for loading a picture on my website depending on which small
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am trying to render a haml file in a javascript response like so:
I am doing a simple coin flipping experiment for class that involves flipping a

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.