Note that there are some explanatory texts on larger screens.

plurals
  1. POJquery doesn't get my value from php file
    primarykey
    data
    text
    <p>I need your help. In my php code I created a date countdown, it works everything, but i have problem with my code in jquery. I am trying to get $json_result value. This is my php code:</p> <pre><code>&lt;?php function addZero($addZero){ return ($addZero &lt; 10) ? '0'.$addZero : $addZero; } header('Content-type: application/json'); $year_value = date('Y'); $end_month = $_GET['month']; $end_day = $_GET['day']; $end_hours = $_GET['hour']; $date = strtotime("$year_value-$end_month-$end_day, $end_hours:00:00"); $remaining = $date - time(); $minutes = floor($remaining/60); $hours = floor($remaining/3600); $daysLeft = floor($remaining/86400); if($daysLeft &gt; 0){ $remaining_hours = $hours - ($daysLeft * 24); }else{ $remaining_hours = $hours; } $remaining_minutes = floor(($remaining - ($hours * 3600))/60); $remaining_seconds = floor($remaining - ($minutes * 60)); $result = 'Days left:&amp;nbsp;'.$daysLeft.'&amp;nbsp;'.addZero($remaining_hours).':'.addZero($remaining_minutes).':'.addZero($remaining_seconds); $json_result = json_encode($result); echo $json_result; ?&gt; </code></pre> <p>And this is my html jquery php code:</p> <pre><code>&lt;head&gt; &lt;script type="application/javascript"&gt; jQuery(document).ready(function(){ $("#submit").click(countDown); }); function countDown(e){ setTimeout(function(){ $.get('countdown.php',function(data){ $("#countDown").html(data); e.preventDefault(); }); countDown(); },1000); } &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;?php $monthsArray = array(0 =&gt; '0', 1 =&gt; 'Jan.', 2 =&gt; 'Feb.', 3 =&gt; 'Mar.', 4 =&gt; 'Apr.', 5 =&gt; 'May', 6 =&gt; 'Jun.', 7 =&gt; 'Jul.', 8 =&gt; 'Aug.', 9 =&gt; 'Sep.', 10 =&gt; 'Oct.', 11 =&gt; 'Nov.', 12 =&gt; 'Dec.'); $months = array_slice($monthsArray, date('m'), 12, true); ?&gt; &lt;label&gt;Month:&lt;/label&gt; &lt;select name="month" id="month"&gt; &lt;?php foreach ($months as $values =&gt; $keys) { printf('&lt;option value="%u"&gt;%s&lt;/option&gt;', $values, $keys); } ?&gt; &lt;/select&gt; &lt;?php $daysArray = array(0 =&gt; '0', 1 =&gt; '1', 2 =&gt; '2', 3 =&gt; '3', 4 =&gt; '4', 5 =&gt; '5', 6 =&gt; '6', 7 =&gt; '7', 8 =&gt; '8', 9 =&gt; '9', 10 =&gt; '10', 11 =&gt; '11', 12 =&gt; '12', 13 =&gt; '13', 14 =&gt; '14', 15 =&gt; '15', 16 =&gt; '16', 17 =&gt; '17', 18 =&gt; '18', 19 =&gt; '19', 20 =&gt; '20', 21 =&gt; '21', 22 =&gt; '22', 23 =&gt; '23', 24 =&gt; '24', 25 =&gt; '25', 26 =&gt; '26', 27 =&gt; '27', 28 =&gt; '28', 29 =&gt; '29', 30 =&gt; '30', 31 =&gt; '31'); if(date('L') == 0 &amp;&amp; (date('m') == 02 || date('m') == 2)){ $days = array_slice($daysArray, date('d'), -3, true); // if it's not a leap year february has 28 days }elseif(date('L') == 1 &amp;&amp; (date('m') == 02 || date('m') == 2)){ $days = array_slice($daysArray, date('d'), -2, true); // if it's a leap year february has 29 days }elseif(date('m') % 2 == 0){ $days = array_slice($daysArray, date('d'), -1, true); // even month }else{ $days = array_slice($daysArray, date('d'), 31, true); // odd month } ?&gt; &lt;label&gt;Day:&lt;/label&gt; &lt;select name="day" id="day"&gt; &lt;?php foreach ($days as $values =&gt; $keys) { printf('&lt;option value="%u"&gt;%s&lt;/option&gt;', $values, $keys); } ?&gt; &lt;/select&gt; &lt;input type="submit" id="submit" value="Submit"&gt; &lt;div id="countDown"&gt; &lt;/div&gt; &lt;/body&gt; </code></pre> <p>Can someone tell me what I'm doing wrong?? And I am using jquery version 1.9.1.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload