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 trialWeng Jeff Lee
12,865 Points$get() make me a little bit confuse
Hello, about an ajax shorthand methods. In this video, i get confuse of this
$.get("sidebar.html", function(response){
$('#ajax').html(response);
})
The argument 'response', what it doing in the function? Is it the response for the 'sidebar.html'?
Thanks for anyone who try to explain.
2 Answers
Leo Picado
9,182 PointsIt is, so whatever comes back from the AJAX GET request will be stored in response, you can print it to the console to check it out, something like:
$.get("sidebar.html", function(response){
console.log(response);
});
More info over at http://api.jquery.com/jquery.get/
Marcus Parsons
15,719 PointsMarked as best answer
Kenneth Kim
3,795 PointsHi I would like to add something to the question.
With what Leo said, if I use the load method -> $('#ajax').load('sidebar.html'); how will i get the response variable? Is is safe to say that I should only use load() if I want to insert html content to the selected ID and use the $.get() to do more like create a custom function (callback) and other stuff ?
Abhishek Bhardwaj
3,316 PointsAbhishek Bhardwaj
3,316 Points" $.get (or) jquery.get() " are both same here $ is jquery selecter and get is a function that contain three argument for example: $.get(url,data,callbak);