Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript AJAX Basics AJAX Concepts AJAX Security Limitations

karan Badhwar
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
karan Badhwar
Web Development Techdegree Graduate 18,135 Points

JSONP

So, as the JSONP requests for the Js file from the other server, so is it storing whatever the data is inside the Js (requested ) file in the JSON file or it's just helps to get the Js file from other server, if the second one is true then why do we need JSON for that, as it just helps to store data in a organized manner?

Caleb Kemp
Caleb Kemp
12,755 Points

So JSONP is essentially doing two things, 1, it sends a query to the server, (what data is needed) 2. it tells the server what function to send the data to.

The server will then send data as a JavaScript function to the local function specified. While the server could send the data in another format (still inside a js function though), it is standard practice to use JSON. JSON is the native storage method in JavaScript and is usually going to be the best way of storing the data. JSON stands for (JavaScript Object Notation).

So, basically yes, JSON is used to make the data easier to work with.