I'm a horrible amateur and don't fully understand the processes of PHP.
I have a shopping cart site that I would like to modify certain functions and add some usability enhancements.
On a main product page, a user can add the product to their cart. On this same product page, a user will also see add on items for the product. These add on items have their own product pages as well.
Generally, when a user clicks on an add on item, it takes them away from the main product page, to the product page of the add on item.
What I would like to do instead have the add on item's information load in a jQuery/CSS3 overlay - and still keep them on the main product page.
I have achieved this using jQuery.load - but the shopping cart (Zen-Cart) has a history snapshot - and the jQuery.load function has some undesirable effects. Furthermore, I would rather load the information directly from the SQL using PHP.
I've had a look at this: http://www.w3schools.com/php/php_ajax_database.asp
and find it to be a more cleaner solution than the jQuery.load.
The trouble I'm having understanding is how the PHP Get will perform in such an environment. For example, two users simultaneously loading the information of an add on item through the getuser.php file. Similarly, one user accessing the information of two add on items by browsing with multiple tabs.
To put it more simple -
If user1 clicks on an add on item, it passes through a variable based on the add on item selected, i.e. xmlhttp.open("GET","getuser.php?q="+str,true)
and if user2 clicks on a different add on item, it does the same thing - but assuming that user2's request is slightly later, will this overwrite the information originally put there by user1's request - thus giving the wrong information to user1? Or will it create multiple instances of the file and avoid the results of both requests interfering with each other? Similarly, what about two requests from the same user at the same time using two browser tabs?
I know how bad this sounds - but I don't know how better to word this I'm so sorry :(
you can use $.get(url,data,response);
in jquery to achieve this. example :
$('#product-list a').on('click',function(){
var id = $(this).data('id');//if you put product id as attribute data
$.get('addtocart.php',{id: id},function(){
$('#cart').load('cart.php'); //only your cart reload. not the page!
}
return false;
}
and in your addtocart.php
$id = $_GET['id']
//your query put here
this is only simple sample. not for use in production. because in real life, you need to concern the security. sorry for my bad english :)
more information visit :