Prev | Current Page 501 | Next

Emilian Balanescu and Cristian Darie

"Beginning PHP and MySQL E-Commerce: From Novice to Professional, Second Edition"

Most languages contain
a DOM component; in the context of AJAX programming, the DOM interface of JavaScript
allows you to read, parse, alter, and create HTML elements of the web page. More often than
not, after receiving the server response to the asynchronous call you??™ve made, you??™ll want to
modify the page accordingly to inform the visitor of the results.
JavaScript provides the default document object that is a DOM representation of the current
page. For example, you can use document.write() to add content to the element
of the page, and you can use document.getElementById() to get an element of the page. For
example, take the following piece of code that edits the content of the
element named
cart-summary:
document.getElementById("cart-summary").innerHTML = response;
?– Caution There??™s one obvious detail you must always keep in mind when modifying the contents of
a page using JavaScript: clients that don??™t support JavaScript won??™t benefit from the new features. The
important features of the web site must notrely on JavaScript being enabled; in other words, the implementations
must be degradable. A particular case of visitors that don??™t execute JavaScript code is web spiders,
such as those from Google, Yahoo, or MSN, indexing your web site. You must not display any important content
using JavaScript because it would be completely invisible to web spiders, which is not something you
can typically afford when you run an online business.


Pages:
489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513