Prev | Current Page 528 | Next

Emilian Balanescu and Cristian Darie

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


This response will be something like this:
{* Start cart summary *}

Cart Summary


Updating...

...

Our JavaScript code must take the contents of the root
element and inject them into the page under the
cart-summary
element. For this we used a regular expression named cartSummaryRegEx:
else
{
// Extract the contents of the cart_summary div element
var cartSummaryRegEx = /^
???
([\s\S]*)<\/div>$/m;
matches = cartSummaryRegEx.exec(response);
response = matches[1];
Alternatively, we could have used the XML DOM or the substring feature of string. The substring method is
the fastest and easiest to implement, but it has the disadvantage that it??™s not flexible. If the format of the output or
the name of the
element changes, it will not work anymore. Here??™s a possible implementation:
response = response.substring(25, response.length - 7);
After obtaining the string, updateCartSummary() uses it to replace the contents of the cart-summary element
of the page, effectively updating the cart summary. The ???Loading...??? text is also hidden:
// Update the cart summary box and hide the Loading message
document.getElementById("cart-summary").innerHTML = response;
// Hide the "Updating..." message
document.


Pages:
516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540
drzwi aluminiowe poker online akademia kyokushin poker no limit pozycjonowanie stron