Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Ajax beginner question

Posted on 2014-04-28
3
Medium Priority
?
200 Views
Last Modified: 2014-04-28
Really just looking for someone to explain the following code. I'm going to keep moving on but it would be appreciated.

Ok so the handler, it seems to me well the syntax is a loop. Can someone explain this concept? I don't see why you can't just have an on click. Is it basically keeping it running keeping the code executing until someone does click? I know that's off.

Second question I get what's going on with the on click and the URL being rendered. I don't get the getDetails(this.title);. I put comments over that code. Not sure what that does.

Final question should I just move through this stuff or is it acceptable to post questions on here?

One more question is this considered or what I will be learning object oriented programming? I have heard that is a modern concept and I have no knowledge of it.
thumbnails.js
0
Comment
Question by:burnedfaceless
  • 2
3 Comments
 
LVL 27

Accepted Solution

by:
BigRat earned 2000 total points
ID: 40027128
This is a typical piece of code which fills out functionality from a server side generated HTML page. Assume that the server has generated a load of images to be displayed on the page (an unknown number of course!) and has included them probably under a DIV element whose ID is thumbnailPane. Then a collection of these image elements is in thumbs after line 5.

We now go through this list, taking each in the variable "image" and we create an onclick function which will modify the src attribute of the image - ie: from where the picture data is loaded - by changing the URL to images/<somename>-details.jpg. The some name is the title attribute of the image tag.

When the onclick function, which has been registered as above is called, the "this" variable points to the HTML element which caused the function to be called, ie: the image tag. Thus this.title refers to the title attribute of the image which was clicked. If you think about it, any function like onclick, or mouseover and so on, must somehow have a reference to the object which was clicked ot under the mouse. This reference is called "this".

HTH
0
 

Author Closing Comment

by:burnedfaceless
ID: 40027155
Cool man it seems a little out of order but I"m trying to rap my brain around it.
0
 

Author Comment

by:burnedfaceless
ID: 40027208
No it makes perfect sense now. Thank you.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
OverviewThis article demonstrates a simple search form using AJAX. The purpose of the article is to demonstrate how to use the same code to render a page and javascript (JQuery) and AJAX to make subsequent calls to refine the results. The princip…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

877 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question