Prev | Current Page 519 | Next

Emilian Balanescu and Cristian Darie

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

link_to_add_product}"
onsubmit="return addProductToCart(this);">
{* Generate the list of attribute values *}


{* Parse the list of attributes and attribute values *}
{section name=l loop=$obj->mProducts[k].attributes}
...
{/section}


{* Add the submit button and close the form *}



CHAPTER 13 ?–  IMPLEMENTING AJAX FEATURES 414



3. Create a new folder in your project??™s root folder (tshirtshop) named scripts, add a new file named
ajax.js in it, and type the following code:
// Holds an instance of XMLHttpRequest
var xmlHttp = createXmlHttpRequestObject();
// Display error messages (true) or degrade to non-AJAX behavior (false)
var showErrors = true;
// Contains the link or form clicked or submitted by the visitor
var actionObject = '';
// Creates an XMLHttpRequest instance
function createXmlHttpRequestObject()
{
// Will store the XMLHttpRequest object
var xmlHttp;
// Create the XMLHttpRequest object
try
{
// Try to create native XMLHttpRequest object
xmlHttp = new XMLHttpRequest();
}
catch(e)
{
// Assume IE6 or older
var XmlHttpVersions = new Array(
"MSXML2.XMLHTTP.6.0", "MSXML2.XMLHTTP.5.0", "MSXML2.XMLHTTP.4.0",
"MSXML2.XMLHTTP.3.0", "MSXML2.XMLHTTP", "Microsoft.XMLHTTP");
// Try every id until one works
for (i = 0; i < XmlHttpVersions.


Pages:
507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531
Sławni Ludzie meble do sypialni wokar Danny bet365