Ajax Updates |
| Posted: 10 Oct 2009 12:49 PM PDT Fly To Basket – Ajax Script Configuration This is the HTML for products on the page <div id="slidingProduct1" class="sliding_product"> <img src="images/product.gif"/> Calendar<br /> 50.00 </div> <a href="#" onclick="addToBasket(1);return false;"><img src="images/basket.gif"/></a> There are two important things you have to notice here:
addProduct.php This is a PHP file which is called by Ajax when a product is added to the basket(It’s not required to use PHP. You can create it in ASP, JSP or other server side language). This file receives a variable named “productId”. Then, this file should update the content of the shopping basket in a database. Finally, it outputs a string in the following format: product ID|||Product description|||product price I.e.: product ID, 3 pipes, product description, 3 pipes and finally the price of the product removeProduct.php productIdToRemove What you have to do inside this PHP file is to subtract one item of this product from the basket(i.e. in the Database). Then output the string “OK” if the update was executed successfully. Javascript variables var flyingSpeed = 25; var url_addProductToBasket = 'addProduct.php'; var txt_totalPrice = 'Total: '; flyingSpeed is used to control how fast your products flies to the basket. showAjaxBasketContent function Showing existing basket items <table id="shopping_cart_items"> <tr> <th>Items</th> <th>Description</th> <th>Price</th> <th></th> </tr> <!-- Here, you can output existing basket items from your database One row for each item. The id of the TR tag should be shoping_cart_items_product + productId, example: shoping_cart_items_product1 for the id 1 --> </table> If there’s allready items in the basket, you have to add rows to this table, example: <tr id="shoping_cart_items_product1"> <td>1</td> <td>Calendar</td> <td>50.00</td> <td><a href="#" onclick="removeProductFromBasket(1);return false;"></a></td> </tr> ![]() Related Listings:
|
| You are subscribed to email updates from Ajax Updates To stop receiving these emails, you may unsubscribe now. | Email delivery powered by Google |
| Google Inc., 20 West Kinzie, Chicago IL USA 60610 | |


0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.