Webtags (preserving history): Difference between revisions

m
*The jQuery get request takes the api URL as first parameter and the function to deal with the returned result as third parameter
*The middle parameter is irrelevant in this context as only one object instance is returned, but if the qet was returning multiple results, "limit=1" would only return the first result
*The function takes as its sole parameter an Object (a JavaScript Object is a collection of properties), this is what is returned by the api, thean selected nameobject can be given any variable name
*In JavaScript if a variable is defined outside the function, then given a value inside the function, that value can be accessed by later code outside the function (in my case by code within the other functions for calculating each derived value)
*We are only interested in 3 of the '''property_name = property_value''' items in the Object.
*The object returned has 3 parameters each in '''attribute=value''' format
*WeThe JavaScript '''refinement''' syntax (starts with a dot) can be used to find the value infor any parameter bywe usingname. We assign the '''object.attribute'''variable syntaxalready defined to the object and assignits itrefinement to(that specifies the variableattribute alreadywe definedwant).
*The console.log command simply outputs all the items in the list within the brackets into the browser console that in many browsers is displayed by selecting '''F12''' on the keyboard. I included this instead of the lengthy rest of my code that uses the units to do the various calculations correctly.
 
5,838

edits