Solved

Ajax beginner question

Posted on 2014-04-28
3
196 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
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

ASP.NET AJAX callbacks to web service are becoming very popular and unavoidable these days. The feel that the user gets when only a part of the page is updated without even hindering the UI is the advantage that the callbacks offer. The wait for the…
Introduction HyperText Transfer Protocol (http://www.ietf.org/rfc/rfc2616.txt) or "HTTP" is the underpinning of internet communication.  As a teacher of web development I have heard many questions, mostly from my younger students who have come to t…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

821 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