Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP and JQuery Button trigger not working
    text
    copied!<p>Im currently new to PHP and JQuery after having using ASP.Net and C Sharp for the 2 years. I have this major problem in which i require some assistance in.</p> <p>I have a HTML <code>&lt;input type="submit" id="btnWL" value="Add to Wishlist"&gt;</code> button. Basically when this button is pressed a table called 'wishlist' in the database is checked to see if the current product is already in a wishlist. If no the button will trigger a database save else it will return a JQuery alert pop up error message.</p> <p>I having difficulty in passing 2 PHP variables: <code>$_SESSION["username"]</code> and <code>$_GET["ProductId"]</code> into this JQuery method:</p> <pre><code>&lt;script type="text/javascript"&gt; $(document).ready(function() { $('#btnWL').live('click', function() { $.post("addToWishlist.php"); }); }); &lt;/script&gt; </code></pre> <p>As you can see this JQuery method must pass those values to an external PHP File which checks for an already exsisting record in the 'wishist' table with those details.</p> <pre><code>&lt;?php $WishlistDAL = new WishlistDAL(); $result = $WishlistDAL-&gt;get_ProductInWishlistById($_GET["ProductId"]); if (isset($_POST["isPostBack"])) { if (isset($_SESSION["username"])) { if (isset($_GET["btnWL"])) { //Check if ProductId is in Cart if (mssql_num_rows($result)&gt;0) { //Return an error //Sumhow this has to trigger an alert box in the above JQuery method } else { //Write in Wishlist Table $WishlistDAL-&gt;insert_ProductInWishlist($_GET["ProductId"], $_SESSION["username"]); } } } else { //Return Error } } ?&gt; </code></pre> <p>Another problem I have is then displaying an alert box using the same JQuery method for any errors that where generated in the php file.</p> <p>Any Ideas how I can implement this logic? Thanks in advance.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload