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

  • SEARCH
  • Home
  • 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 8975599
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T18:55:18+00:00 2026-06-15T18:55:18+00:00

My program is checking for a winner in my blackjack game after the user

  • 0

My program is checking for a winner in my blackjack game after the user clicks “stand”.
When I try calling the winner with AJAX, I want to see if there is a winner. If yes, then alert the winner. Else, allow the dealer to make his move. Any help would be greatly appreciated.

Sample result/output after stand: User hand = dQ, hJ; val = 20 – alerts ” wins! in stand”

Expected result after this hand: – go to ajaxDealer(user);

php code:
($checkPlayerHandValue works fine, i.e. if User has C5,HQ, will return 15)

function checkWinner($u, $d, $uValue) {
    if($uValue > 21)
        return $d;
}

if($checkPlayerHandValue > 0) {
    $checkPlayerHandValue = checkPlayerHandValue($user);
    $winner = checkWinner($user, $dealer , $checkPlayerHandValue);
}

 $row = mysql_fetch_array($checkNextTurn);
 $playerTurn = $row['user'];
 echo($playerTurn."|");
 echo($winner);

js code:

xmlhttpB.onreadystatechange=function() {
            if (xmlhttpB.readyState==4 && xmlhttpB.status==200) {
                elements = xmlhttpB.responseText.split("|");
                user = elements[0];
                winner = elements[1];
                //alert(winner);
                if(winner != "")
                    ajaxDealer(user);
                else 
                    alert(winner + " wins! in stand");              

            }
            clickButton = true;
        }
  • 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-06-15T18:55:20+00:00Added an answer on June 15, 2026 at 6:55 pm

    Do yourself a favor and start using the jQuery library with it’s AJAX module.

    As far as your question goes, can you tell us what the current problem with your code is (what is not happening that should be happening, or vice versa).

    Also, I think this logic is incorrect:

    if(winner != "")
       ajaxDealer(user);
    else 
      alert(winner + " wins! in stand"); 
    

    And should be flipped:

    if(winner == "")
       ajaxDealer(user);
    else 
      alert(winner + " wins! in stand");     
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an array of uint-types in C#, After checking if the program is
I'm writing an interpreter for a compiler program in Java. So after checking the
After spending a week checking and fixing my program for memory leaks through FastMM4,
I'm trying to write a simple spell checking program for homework, basically by putting
Im bug checking a c program and would like to install valgrind, the system
My installer is checking if the program is already installed and I would like
Possible Duplicate: Performance difference between gcc and g++ for C program I was checking
I have a problem here... After a button is pressed I want a loop
In Program.cs I have the below method that is checking and the Syncing 5
I am currently checking the keyboard state in my program: SlimDX.DirectInput.KeyboardState keyboardState = keyboard.GetCurrentState();

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.