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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T12:40:02+00:00 2026-06-16T12:40:02+00:00

I am creating a simple JSON API that just returns me an object using

  • 0

I am creating a simple JSON API that just returns me an object using jsonp using node-js
Here is the code for server side :

app.get('/vit',function  (req,res,next) {
    res.type('application/json');
    res.jsonp(items);  //items is the object
});

On deploying to nodejitsu , and going to url /vit i get the object items.That means its working on the server side.

I have another domain from where I wanna get this object using jsonp
Heres the client-side code :

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript">
    $.getJSON('http://trial.jit.su/vit',function  (data) {
       console.log(data) ;
    });
</script>

But I get the following error on the console:

XMLHttpRequest cannot load http://trial.jit.su/vit. Origin http://jquer.in is not allowed by Access-Control-Allow-Origin.

Seems like I have not understand Jsonp.

  • 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-16T12:40:04+00:00Added an answer on June 16, 2026 at 12:40 pm

    Quoting the jQuery docs

    If the URL includes the string “callback=?” (or similar, as defined by the server-side API), the request is treated as JSONP instead. See the discussion of the jsonp data type in $.ajax() for more details.

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

    You need a query string param with a question mark as placeholder.

    And looking at the response of http://trial.jit.su/vit you’re missing the callback function. You’re just returning plain JSON without the P, e.g. if the url contains ?callback=bacon your response needs to be

    bacon({"your": "json string"});
    

    But express will do this for you, as long as you supply a callback param.

    So just change the following:

    $.getJSON('http://trial.jit.su/vit?callback=?',function  (data) {
        console.log(data) ;
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am creating a simple web API that returns JSON. It will perform simple
I'm creating a simple API that creates typed classes based on JSON data that
I'm creating a RESTful API that returns JSON or XML depending on the Accept
I am creating a simple REST API that outputs JSON data. However I am
I finished Ryan Bates #348 video for creating a JSON API using the rails-api
I am building a simple service(API) that will return json reponse of users objects
I been following this tutorial on creating a simple API with Node.js and MongoDB,
I'm using json simple to create and parse some json. However, after creating it,
Creating a simple RPG game, first time using XNA. Trying to get my character
I'm working on creating a WCF web service that communicates via JSON. I got

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.