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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T09:00:50+00:00 2026-06-14T09:00:50+00:00

I am using angular’s $http.jsonp() request which is successfully returning json wrapped in a

  • 0

I am using angular’s $http.jsonp() request which is successfully returning json wrapped in a function:

var url = "http://public-api.wordpress.com/rest/v1/sites/wtmpeachtest.wordpress.com/posts?callback=jsonp_callback";

$http.jsonp(url).
    success(function(data, status, headers, config) {
        //what do I do here?
    }).
    error(function(data, status, headers, config) {
        $scope.error = true;
    });

How to access/parse the returned function-wrapped-JSON?

  • 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-14T09:00:52+00:00Added an answer on June 14, 2026 at 9:00 am

    UPDATE: since Angular 1.6

    You can no longer use the JSON_CALLBACK string as a placeholder for
    specifying where the callback parameter value should go

    You must now define the callback like so:

    $http.jsonp('some/trusted/url', {jsonpCallbackParam: 'callback'})

    Change/access/declare param via $http.defaults.jsonpCallbackParam, defaults to callback

    Note: You must also make sure your URL is added to the trusted/whitelist:

    $sceDelegateProvider.resourceUrlWhitelist

    or explicitly trusted via:

    $sce.trustAsResourceUrl(url)

    success/error were deprecated.

    The $http legacy promise methods success and error have been deprecated and will be removed in v1.6.0. Use the standard then method instead. If $httpProvider.useLegacyPromiseExtensions is set to false then these methods will throw $http/legacy error.

    USE:

    var url = "http://public-api.wordpress.com/rest/v1/sites/wtmpeachtest.wordpress.com/posts"
    var trustedUrl = $sce.trustAsResourceUrl(url);
    
    $http.jsonp(trustedUrl, {jsonpCallbackParam: 'callback'})
        .then(function(data){
            console.log(data.found);
        });
    

    Previous Answer: Angular 1.5.x and before

    All you should have to do is change callback=jsonp_callback to callback=JSON_CALLBACK like so:

    var url = "http://public-api.wordpress.com/rest/v1/sites/wtmpeachtest.wordpress.com/posts?callback=JSON_CALLBACK";
    

    And then your .success function should fire like you have it if the return was successful.

    Doing it this way keeps you from having to dirty up the global space. This is documented in the AngularJS documentation here.

    Updated Matt Ball’s fiddle to use this method: http://jsfiddle.net/subhaze/a4Rc2/114/

    Full example:

    var url = "http://public-api.wordpress.com/rest/v1/sites/wtmpeachtest.wordpress.com/posts?callback=JSON_CALLBACK";
    
    $http.jsonp(url)
        .success(function(data){
            console.log(data.found);
        });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create a POST request using angular.js to this Django view. class
I have several TextBoxes, which display angular values. I format these using different custom
I'm using Express, which loads AngularJS from a static directory. Normally, I will request
Angular.js, when accessing a web service using the $http object, automatically adds a X-Requested-With:XMLHttpRequest
I'd like to use socketstream's RPC over websockets abstraction while using Angular for MVC.
using this http://bl.ocks.org/950642 we can see how to add images to nodes, the question
I am using Angular.js for an application that uses hidden trs to simulate a
I'm creating two POST calls. One using a django form and one using angular
I'm using AngularJS with Rails and creating dynamic nested form items which are not
What is the use of using angular tag in css ie, .class << span

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.