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

<p>Here is my code:</p>

<p>HTML:</p>

<pre><code>&lt;div class='jcontainer' data-param='jcontainer_IDNUMBER'&gt;

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

&lt;/div&gt;
</code></pre>

<p>jQuery:</p>

<pre><code>&lt;script type="text/javascript"&gt;
$(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
</code></pre>

<p>and php page:</p>

<pre><code>&lt;?php

$hostname = 'localhost';

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

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

$apptid = $_POST['dataid'];

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

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

?&gt;
</code></pre>

<p>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. </p>

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

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