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 (retiring) AJAX and APIs Making the AJAX Request

Floyd Orr
Floyd Orr
11,723 Points

what does getJSON() do that regular get() can't do?

I must be missing something. What is the advantage or one over the other?

2 Answers

Merritt Lawrenson
Merritt Lawrenson
13,477 Points

Both are shorthand methods in jQuery. 'getJSON()' gets JSON, whereas 'get()' requires you to specify the datatype yourself. 'getJSON()' is just one argument shorter.

For more info:

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

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

Michael Fish
Michael Fish
7,804 Points

Hello Floyd,

I believe the get() method can return multiple things from the server. getJSON() is purely for JSON encoded data. I assume getJSON() is just a more specific way to use the get() method. Hope this was helpful!

Mike

Floyd Orr
Floyd Orr
11,723 Points

Thank you Mr Fish