Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Uncaught SyntaxError: Unexpected end of JSON input
- at JSON.parse (<anonymous>)
- at XMLHttpRequest.xmlhttp.onreadystatechange
- unction chatTest() {
- var xmlhttp = getXmlHttp();
- xmlhttp.open("POST","functionsTest.php",true);
- xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
- xmlhttp.send("update=1");
- xmlhttp.onreadystatechange = function(){
- if (xmlhttp.readyState == 4) {
- if (xmlhttp.status == 200) {
- var response = xmlhttp.responseText;
- response = JSON.parse(response);
- if (array.length == response.length) return;
- var start = array.length;
- array = response;
- var message = document.getElementById("chat").innerHTML;
- for (i = start; i < array.length; i++) {
- message = message + "<p><b>" + array[i].name + ":</b> " + array[i].message + "</p>"
- }
- document.getElementById("chat").innerHTML = message;
- document.getElementById("chat").scrollTop = 1000000;
- }
- }
- }
- setTimeout("chatTest()", 1000);
- }
- elseif(isset($_POST["update"])) {
- $string = file_get_contents("messageTest.txt");
- $array = explode("n", $string);
- $result = array();
- for ($i = 0; $i < count($array); $i++) {
- $temp = explode(";", $array[$i]);
- $result[$i]["name"] = $temp[0];
- $result[$i]["message"] = $temp[1];
- }
- echo json_encode($result); }
Add Comment
Please, Sign In to add comment