>> SPEAKER: Let's improve upon that last example a bit further.
This time, rather than using the alert function, which creates a window that
varies aesthetically from browser to browser, let's instead embed the
latest stock price inside of my page itself-- that is, inside
of the page's dom.
>> Notice here, in ajax-2.html, I've added an additional line that
specifies Price colon, followed by a span, which is sort of like a division
of the page, but it doesn't break onto a new line.
And that span has an ID attribute whose value is price, and some default
text inside of these open and close tags that simply says to be
determined.
>> Meanwhile, up here in my page's head, I have a script tag as before.
I construct a URL to quote.php, passing in a symbol as an HTTP
getParameter, and I call jQuery's getJSON function as before.
But the line of code that I'm now going to write when I receive the data
from quote.php, as a JSON object, is dollar sign, quote, unquote, pound,
price, thereby specifying that I'd like to get element from my dom, whose
unique identifier is price.
>> And I'd like to then call a function or method inside of that called html,
which says update the HTML of that element to be, in this case,
data.price.
>> Let's now save the file and open this page in my browser.
http://localhost/ajax-2.html--
there's that same form, but this time with a price beneath it.
Let's type in a symbol like FB for Facebook and type Get Quote.
And rather than see an alert window this time, we instead see in my page's
dom Facebook's latest stock price.