Jump to content

When clicked, the value can not pass to input element without reload page.


Recommended Posts

when i click button .btnStart, i would like to INPUT class="stime" to have value $resp['start'] without page reload. but not work. any help?


JS code

        $(".btnStart").click( function() {
            var tid = $(this).data("tid")
                {"ajax":"startBooking", "tid":tid},
                function(resp) {



##   Handle AJAX requests  
    if ($_GET['ajax'] == 'startBooking') {
        $dt = new DateTime('now');
        $start = $dt->format('Y-m-d H:i:s');
        $st = $dt->format('H:i');
        $sd = $dt->format('Y-m-d');
        $stmt = $pdo->prepare("INSERT INTO table_booking (table_id, start_time) VALUES (?, ?)");
        $stmt->execute( [ $_GET['tid'], $start ] );
        $bid = $pdo->lastInsertId();
        $resp = [ "bid" => $bid,
                  "start" => $st,
                  "sdate" => $sd
        exit( json_encode($resp));


<input type='time' class='stime' value='$st' data-tid='{$r['tid']}'>


Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.