Solved

Ajax beginner question

Posted on 2014-04-28
3
197 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
AJAX to call a method 3 74
jquery, populate, auto complete 8 55
Auto refresh part of an MVC5 View 7 120
showing loader for php/mysql/ajax live search 13 82
Introduction A frequently asked question goes something like this:  "I am running a long process in the background and I want to alert my client when the process finishes.  How can I send a message to the browser?"  Unfortunately, the short answer…
I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

739 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