Solved

Ajax beginner question

Posted on 2014-04-28
3
193 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 500 total points
Comment Utility
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
Comment Utility
Cool man it seems a little out of order but I"m trying to rap my brain around it.
0
 

Author Comment

by:burnedfaceless
Comment Utility
No it makes perfect sense now. Thank you.
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Introduction Got endorsements from your clients?  Great!  There is almost nothing better than word-of-mouth advertising.  But how can you do that on the internet?  Sure you can make a page for endorsement quotations and list them all, but who is …
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, …
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

763 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

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now