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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T22:12:11+00:00 2026-06-14T22:12:11+00:00

I’m a pretty novice programmer who is making an application where there are multiple

  • 0

I’m a pretty novice programmer who is making an application where there are multiple divs with a class of jcontainer. Each jcontainer has an id associated with it, which corresponds with a field called apptid in a database. In the Jquery, I send out an AJAX request every five seconds to a php page to retrieve a field called currentlocation in the database (that corresponds with the apptid), which happens for each jcontainer.

Here is my code:

HTML:

<div class='jcontainer' data-param='jcontainer_IDNUMBER'>

  <button class='checkIn' data-param='button_IDNUMBER'>Check In</button>
  <form method='post' class='myForm' action=''>
       <select name='locationSelect' class='locationSelect' data-param='location_IDNUMBER'>
            <option value='1'>Exam Room</option>
            <option value='2'>Exam Room 2</option>
            <option value='3'>X-Ray Room</option>
            <option value='1000'>Check Out</option>
       </select>
  </form>
  <div class='finished' style='color:#ff0000;'>Checked Out</div>

</div>

jQuery:

<script type="text/javascript">
$(document).ready(function() {

  setInterval(function(){

    $('.jcontainer').each(function() {
        var $e = $(this);
        var dataid = $e.data("param").split('_')[1] ;

        $.ajax({
            url: 'heartbeat.php',
            method: 'post',
            contentType: "application/json",
            dataType: "json",
            data: dataid,
            success: function(data){
                var msg = $.parseJSON(response);
                alert(msg);
            }
        });

    });
  },5000);

  //other code that I didn't post, because it's not really relevant, but can post if needed be

and php page:

<?php

$hostname = 'localhost';

$username = '******';

$password = '*************';

$apptid = $_POST['dataid'];

$db = new PDO("mysql:host=$hostname;dbname=sv", $username, $password);
$statement = $db->prepare("SELECT currentlocation FROM schedule WHERE apptid = :apptid");
$statement->execute(array(':apptid' => $apptid));
$row = $statement->fetch();

$currentlocation = array('CurrentLocation' => $row['currentlocation']);
echo json_encode($currentlocation);

?>

The problem is I can’t get any response from the alert(msg). Why is this? I checked Chrome Developer and no errors came up.

The end goal is to have the currentlocation number recorded in a jquery variable. ex -> var currentLocation = Number

Thanks for any and all help, and if you need more details to clear things up, I can happily post!

  • 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-14T22:12:12+00:00Added an answer on June 14, 2026 at 10:12 pm

    This block of code:

    success: function(data){
                var msg = $.parseJSON(response);
                alert(msg);
            }
    

    should read

    success: function(data){
                var msg = $.parseJSON(data);
                alert(msg);
            }
    

    cause the response variable is not declared and undefined so you should use the data variable in your parseJSON method as that is the actual data received. Hope this solves it for you.

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

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
Basically, what I'm trying to create is a page of div tags, each has
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I've got a string that has curly quotes in it. I'd like to replace
In my XML file chapters tag has more chapter tag.i need to display chapters
I am doing a simple coin flipping experiment for class that involves flipping a
I have an array which has BIG numbers and small numbers in it. I
I know there's a lot of other questions out there that deal with this

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.