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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T15:19:34+00:00 2026-06-09T15:19:34+00:00

Take a look at this fiddle : http://jsfiddle.net/3JRU6/ $(document).ready(function(){ var url=’http://api.worldbank.org/topic/4?per_page=10&format=json&callback=?’; var query; $(‘button’).click(function(){

  • 0

Take a look at this fiddle : http://jsfiddle.net/3JRU6/

$(document).ready(function(){
var url='http://api.worldbank.org/topic/4?per_page=10&format=json&callback=?';
var query;
  $('button').click(function(){
    $.getJSON(url,function(json){
      $.each(json.results,function(i,data){
          window.alert("found");
         $("#results").append('<p>'+data.value+'</p>');
      });
    });
  });
});​

I want to connect to the worldbank’s opendata but when I hit the button, nothing happens. I’ve tried the same script with the twitter API and then it did work. The original link is without the &callback=? but I had to add it because I got an error.

Thanks in advance!

  • 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-09T15:19:35+00:00Added an answer on June 9, 2026 at 3:19 pm

    The getJSON method will make a JSONP call if the URL contains a callback property.

    “If the URL includes the string “callback=?” (or similar, as defined
    by the server-side API), the request is treated as JSONP instead.”

    Ref: http://api.jquery.com/jQuery.getJSON/

    The request works fine, and the data arrives to the browser, but as the response is JSON and not JSONP, the data is just discarded and the success callback method will not be called.

    I tried to change format=json to format=jsonp in the URL, but the response is an error message:

    <fault>
            <faultstring>Fault raised in a policy</faultstring>
            <detail>
                <errorcode>31326</errorcode>
                    <trace>
                        Fault Name: JSONP Bad Request
                        Error Type: MessageRouter
                        Description: Fault raised in a policy
                        Service: worldbank
                        Endpoint: target
                        Operation (Target):defaultOperation
                        FlowTransitionState : Target_Request_User_Error
                        Policy : EnforceMediationOnRequestPolicy
                        RaiseFaultAssertion
                    </trace>
            </detail>
    </fault>
    

    You have to check with your API provider on how to make a JSONP request instead of a JSON request.

    Edit:

    As Jimmy Oliger says, the API uses a prefix property instead of callback. I tried this, and jQuery actually uses that property instead, and the success callback is called.

    The response is an array where the first item is paging information, and the second item is the array containing the data, so loop json[1] to show the data:

    Demo: http://jsfiddle.net/Guffa/3JRU6/4/

    var url = 'http://api.worldbank.org/topic/4?per_page=10&format=jsonp&prefix=?';
    var query;
    $('button').click(function() {
        $.getJSON(url, function(json) {
            $.each(json[1], function(i, data) {
                $("#results").append('<p>' + data.value + '</p>');
            });
        });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi please take a look at this fiddle http://jsfiddle.net/bloodygeese/pwjNQ/1/ I am trying to figure
Please take a look at this fiddle: http://jsfiddle.net/KA85s/3/ JQ-UI sets first option as default.
Take a look at this fiddle: http://jsfiddle.net/FK3cd/3/ What I want is for the <li>
If you take a look at this fiddle in Chrome: http://jsfiddle.net/up4Fa/ You will see
Possible Duplicate: .prop() vs .attr() Please take a look at this fiddle: http://jsfiddle.net/DGzvP/ $(#test).prop({
Please take a look at this fiddle: http://jsfiddle.net/d3uc9/4/ I have a problem with this,
Please take a look at this fiddle: http://jsfiddle.net/hughbe/QYGcq/ As you can see, the label
please take a look at this fiddle : http://jsfiddle.net/cX47v/1 I am simply trying to
Take a look at this fiddle: http://jsfiddle.net/WTcgt/ Why is the BOX1 pushed down by
take a look at this code: $(document).ready(function() { document.getElementById(sliderId).onmousedown = sliderMouseDown; }); function sliderMouseDown()

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.