Example #1
0
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>

<?php 
include 'getItems.php';
$result = RetrieveItems();
?>

<script>
var RETRY_INTERVAL = 5000;
var customerId = Math.floor((Math.random() * 999) + 1);
var items = <?php 
echo $result;
?>
;

function loadItems(items){
    if (items.error !== undefined) {
        reloadCatalog();
        return;
    }
    var i = 0;
    console.log("Load Items: " + items.rows);
    document.getElementById("loading").innerHTML = "";
    for(i = 0; i < items.rows.length; ++i){
        addItem(items.rows[i].doc);
    }
}

function reloadCatalog() {
    showErrorMessage("The catalog is not currently available, retrying...");
    window.setTimeout(
Example #2
0
<?php

include 'getItems.php';
$result = RetrieveItems($catalogRoute . "/items");
if (isset(json_decode($result)->errno)) {
    http_response_code(500);
}
echo $result;
?>