javascript - I have Jquery set to read a JSON file but only i see it on the website? -
i have few friends helping me out going on website see if comes up, show me nothing comes up, , me stuff json file shows me
php file ajax:
<?php include '../filter.php'; $chatjson = file_get_contents('chats.json'); $chatarray = array(); $sender = securepost($_post["sender"]); $message = securepost($_post["message"]); if ($sender || $message) { $chatarray[] = array('sender' => $sender, 'message' => $message); if (json_decode($chatjson)) { $chatarray[] = json_decode($chatjson); } file_put_contents("chats.json",json_encode($chatarray)); } ?>
ajax
var j = jquery.noconflict(); var chats = []; var xhr; if (window.xmlhttprequest) { xhr = new xmlhttprequest(); } else if (window.activexobject) { xhr = new activexobject("msxml2.xmlhttp"); } else { throw new error("ajax not supported browser"); } j(document).ready(function() { setinterval(function(i){ $.getjson( "/chatting/chats.json", function( data ) { var txt = ""; var x; (x in data) { txt += data[x] + " <br />"; } document.getelementbyid("json").innerhtml = json.stringify(data); }); }, 1000) });
what comes me: picture comes up
for friends, same thing nothing comes up.
Comments
Post a Comment