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 8556479
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T15:21:39+00:00 2026-06-11T15:21:39+00:00

Can someone please help? Here is my jQuery. The scenario is this, I have

  • 0

Can someone please help? Here is my jQuery. The scenario is this, I have a table where it has a button on with every <td>.If you click that button a modal window will appear with a confirmation button on it with yes or no. If the user clicks yes (#confirm_cancel), this will save in the database then show an alert box wherein it tells the users that the update was successful. The problem is this, it properly executes my SQL and saves to the database but I get an alert box on error function that says [object object].

This is my PHP:

<?php
include("php/openDB.php"); 

echo '<table border="2" id="tableGuestList">';
echo '<tr>';
    echo '<td>Guest ID</td>';
    echo '<td>Room No:</td>';
    echo '<td>First Name</td>';
    echo '<td>Last Name</td>';
    echo '<td>Checkin</td> ';
    echo '<td>checkout</td>';
    echo '<td>Status</td>';
    echo '</tr>';

    $result = mysql_query("SELECT gi.guest_id, gi.fname, gi.lname, bk.checkin, bk.checkout, bk.transacstatus, bk.reserved_id "
    ."FROM tbl_guestinfo gi, tbl_bookings bk "
    ."where gi.guest_id = bk.guest_id "
    ."AND bk.transacstatus = 'booked'");

    while ($rows = mysql_fetch_array($result, MYSQL_NUM)) {
        $guest_id = $rows[0];

        $fname = $rows[1];
        $lname = $rows[2];
        $checkin = $rows[3];
        $checkout = $rows[4];
        $transacstatus = $rows[5];
        $reservedid = $rows[6];


        echo '<tr id="'.$rows[0].'" class="bookedClass">';
        echo '<td>'.$guest_id.'</td>';
        echo '<td> room number kaara</td>';
        echo '<td> '.$fname.'</td>';
        echo '<td>'.$lname.'</td>';
        echo '<td> '.$checkin.'</td>';
        echo '<td>'.$checkout.'</td>';
        echo '<td> '.$transacstatus.'</td>';

        echo '<td style="display:none"> '.$reservedid.'</td>';

        echo '<td> <input type = "submit" value = "Cancel Booking" name ="cancel_booking" /></td>';

        echo '<td> <input type = "submit" value = "Check in" name ="check_in" /></td>';

        //echo '<td> <input type = "submit" value = "Check Out" name ="Check_Out" /></td>';
        echo '</tr>';
    }

    mysql_free_result($result);

    echo '</table>';

    include("php/closeDB.php");
?>

this is my jquery

 $(document).ready(function(){
    var selGuest;
    $('#tableGuestList .bookedClass').click(function(){
        selGuest = $(this).find("td").eq(7).text();
        selGuest = parseInt(selGuest)
        $('#confirmDialog').fadeIn('slow');
    });

    $('#confirm_cancel').click(function() {
        var canceldata_json = {
            'selGuest': selGuest,
        };
        $.ajax({
            type: "POST",
            data: canceldata_json,
            url: "./php/cancelBooking.php",
            success: function(msg) {
                alert("guest information updated")
                $('#confirmDialog').fadeOut('slow');
            },
            error: function(msg){
                alert(msg)
            }
        });
    });

    $('#cancel_cancel').click(function() {
        $('#confirmDialog').fadeOut('slow');
    });
});

and here is my PHP code being called by the AJAX

<?php

// get data
$selGuest = $_POST["selGuest"];

include("openDB.php");

$insertintoCanceled = "insert into tbl_canceled "
        ."reserved_id, `guest_id`,`checkin`, `checkout`, `type_id`, `numAdults`, `numChildren`, `transacstatus`, `amountDue`"
        ."("
        ."SELECT * FROM `tbl_bookings` where `reserved_id` =" .$selGuest
        .")";
if(!mysql_query($insertintoCanceled, $con))//if it fails
{
    die('Error: ' . mysql_error() . "\n");//show the mysql error
}
include("closeDB.php");
?>
  • 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-11T15:21:40+00:00Added an answer on June 11, 2026 at 3:21 pm

    This may be caused by alert(msg). msg may be an object, and the actual data you want is one of its property values. Try setting a breakpoint within Chrome dev tools or Firebug within the error function and inspecting what value msg contains. It may be as simple as using alert(msg.d) instead.

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

Sidebar

Related Questions

Can someone please help me out with a JavaScript/jQuery solution for this arithmetic problem:
can someone please help me. why does this return an error: Dim stuff As
Could someone please help explain why I can't get this to work? I properly
Please can someone help? I have the following code which uploads a file to
Can someone please help be take apart the elements here and help me understand
Can someone please help me with MySQL Trigger Lets say I have two Tables
I wonder whether someone can help me please. I've put together this page which
I was wondering if someone can please help me with a jQuery script. I
Can someone please help to clarify? Also, please mention if there are other representation
can someone please help me out? I'm trying to create an input dynamically with

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.