Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6964317
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T15:54:35+00:00 2026-05-27T15:54:35+00:00

Im currently new to PHP and JQuery after having using ASP.Net and C Sharp

  • 0

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.

I have a HTML <input type="submit" id="btnWL" value="Add to Wishlist"> 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.

I having difficulty in passing 2 PHP variables: $_SESSION["username"] and $_GET["ProductId"] into this JQuery method:

<script type="text/javascript">
            $(document).ready(function() {
                $('#btnWL').live('click', function() {
                    $.post("addToWishlist.php"); 
                });
            });
</script>

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.

<?php    

    $WishlistDAL = new WishlistDAL();
    $result = $WishlistDAL->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)>0)
            {
                //Return an error
                //Sumhow this has to trigger an alert box in the above JQuery method

            }
            else
            {
                //Write in Wishlist Table
                $WishlistDAL->insert_ProductInWishlist($_GET["ProductId"], $_SESSION["username"]);                
            }        
        }    
      }
      else
      {
          //Return Error
      }      
    }
?>

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.

Any Ideas how I can implement this logic? Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T15:54:35+00:00Added an answer on May 27, 2026 at 3:54 pm

    Your “$.post()” call isn’t passing any parameters, and has no callback for interpreting the results:

    $.post('addToWishlist.php', { username: something, password: something }, function (response) {
    });
    

    The “something” and “something” would probably come from your input fields, so:

    $.post('addToWishlist.php', { username: $('#username').val(), password: $('#password').val() }, function (response) {
    });
    

    Now the callback function would interpret the response from the server:

    $.post('addToWishlist.php', { username: $('#username').val(), password: $('#password').val() }, function (response) {
      if (response === "FAIL") {
        alert("fail");
      }
      else {
        // ... whatever ...
      }
    });
    

    Exactly what that does depends on your server code; that “FAIL” response is something I just made up as an example of course.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Currently, I have this line: $.post(submitmail.php, $(#contactform).serialize(), recvMailStatus); I'm new to jQuery so this
I'm extremely new to using jQuery/JavaScript, so please don't judge me if this is
Currently, I am working on restructuring an existing code base. I'm new to php
I'm currently building a new online Feed Reader in PHP. One of the features
I'm currently adding some new extended classes to this code: foreach (BaseType b in
I'm currently planning a new web project. Clients are going to connect using a
I am currently building a php form utilising the jQuery iPhone style radios (found
Here's my situation: using PHP and MySQL as my backend, jQuery and jsTree for
I am using jQuery to build an array of images from a php array.
I am very new in javascript and jquery. $.getJSON(idcheck.php?callback=?, { url: /*i want full

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.