Hi every one, I need help with this js code, some one made this code for me on digitalpoint forum but i have a small issue with this and i am not getting reply from him anymore. About js code: When i click on the "Add to Cart" button it shows instantly, i have a form action to addtocart.php in that file i am using redirect code header("Location: ".$_SERVER['HTTP_REFERER']); i want when page redirect back to the products page then this popup should show. <!DOCTYPE html> <html> <head> <style> div#showcart { width:430px; height:50px; background:#ffd2d3; border: solid 3px #df8f90; color:#c7242e; font-size:16px; font-weight:bold; text-align:center;line-height:50px;display:none; } </style> <script src="http://code.jquery.com/jquery-latest.js"></script> </head> <body> <input type="submit" class="click" value="addtocart"> <div id="showcart">Product #128339 Was Just Added To Your Cart </div> <script> $('.click').click(function () { $("#showcart").fadeIn("slow").delay('800').fadeOut("slow"); }); </script> </body> </html> Code (markup): Old thread can be found here https://forums.digitalpoint.com/threads/javascript-a-small-pop-up-animation-needed.2632861/
make your php redirect code append some custom var to the url like header("Location: ".$_SERVER['HTTP_REFERER'].'?aaa=bbb'); and then in the page add php code like if(isset($aaa)) { display the javascript popup code here.. } or simply check if the $_SERVER['HTTP_REFERER'] is addtocart.php and display the javascript popup code
Hi, thanks for response. I am very beginner. Can you please make 2 pages one is js popup and other one is php redirect and should all working fine. That will be your great pleasure. Advance thanks
My question would be why are you wasting a ton of scripting on making the submit take longer than it has to? Typical example of scripting for nothing, WITH jQuery bloat to boot! I mean, if you were AJAX doing the send or something MAYBE, but don't add even more delay to the slow process of a submit... particularly since without a return value or hook that shouldn't even WORK in most browsers.