Prev | Current Page 546 | Next

Emilian Balanescu and Cristian Darie

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

At onsubmit time, we read the value of placingOrder. This is true after the Place Order button is clicked;
therefore, we return true so that the form will be submitted in the usual way.We also make sure not to send
the place_order form element during cart-update AJAX requests. Modify the executeCartAction()
function in ajax.js as highlighted:
// Called on shopping cart update actions
function executeCartAction(obj)
{
// Degrade to classical form submit for Place Order action
if (placingOrder) return true;
// Display "Updating..." message
document.getElementById('updating').style.visibility = 'visible';
// Degrade to classical form submit if XMLHttpRequest is not available
if (!xmlHttp) return true;
// Save object reference
actionObject = obj;
// Initialize response and parameters
response = '';
params = '';
// If a link was clicked we get its href attribute
if (obj.tagName == 'A')
{
url = obj.href + '&AjaxRequest';
}
// If the form was submitted we get its elements
else
{
url = obj.action + '&AjaxRequest';
formElements = obj.getElementsByTagName('INPUT');
if (formElements)
{
for (i = 0; i < formElements.length; i++)
{
if (formElements[i].name != 'place_order')
{
params += '&' + formElements[i].name + '=';
params += encodeURIComponent(formElements[i].value);
}
}
}
}
CHAPTER 14 ?–  ACCEPTING CUSTOMER ORDERS 440
4.


Pages:
534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558
Pozycjonowanie pozycjonownie Wizzair noclegi agencja detektywistyczna