javascript - AJAX get() data -


i have block of jquery uses $.get() method in setinterval(). don't understand how data second url jquery code.

jquery:

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>    <script type="text/javascript"> setinterval(function() { $.getjson("check_time.php", function(update) {     if (update) {         $("#slideshow").load("phppage.php");     } }); }, 600000); </script> 

php - check_time.php

<?php require_once('connect_pdo.php'); header('content-type: application/json'); $stmt = $conn->prepare("$sqlst = $conn->prepare("select count(*) count                      ads                      lastupdate > now() - interval 10 minute"); $sqlst->execute(); $row = $sqlst->fetch();"); $stmt ->execute(); $row = $stmt ->fetch(); $update = $row['count'] > 0; $updtstatus =  json_encode($update); echo "$updtstatus";    ?> 

i not getting variable check_time.php update variable in function(update).

small alter in php page

$updtstatus =  json_encode(array('count'=>$update)); echo $updtstatus; 

now json in fact {"count":"true"}. change if statement slightly.

   $.getjson("check_time.php", function(update) {         if (update.count===true) {             $("#slideshow").load("phppage.php");         } else {             console.log("no results");         }     }); 

this fiddle simulates above answer


Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

java - Digest auth with Spring Security using javaconfig -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -