Can anyone explain the meaning of this code?
if (data.result) {
$('ul#intlist').append(data.content);
}
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
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.
This code is basically checking whether some data exists
if(data.result)and then appends the content of the data to the end of anulwith an ID ofintlistSo if you had an UL as follows:
Then the jQuery code would be inserting the result of
data.contentto this list.In jQuery you can use CSS selectors to gain access to the elements you want. If you were to do
$('ul')this would give you access to all ul’s on the page. If you were to do$('#intlist')this would give you access to an element with an id of “intlist”. You can combine these selectors as in your code above so that$('ul#intlist')is getting an ul with the id of “intlist”. The hash#symbol is used to obtain items by Id.You can read more about jQuerys
append()method here: http://api.jquery.com/append/