I recently created this .html file :
<?php ?> <html> <head> <title>Feri`s Chat</title> <script src="http://code.jquery.com/jquery-1.9.0.js"></script> <script> function submitChat(){ if(form1.uname.value == '' || form1.msg.value == ''){ alert('Kerlek irj be egy nevet es egy uzenetet is :S'); return; } var uname = form1.uname.value; var msg = form1.msg.value; var xmlhttp = new XMLHttpRequest(); xmlhttp.onreadystatechange = function(){ if(xmlhttp.readyState==4&&xmlhttp.status==200){ document.getElementById('chatlogs').innerHTML = xmlhttp.responseText;} } xmlhttp.open("GET","insert.php?uname="+uname+"&msg="+msg,true); xmlhttp.send(); } $(document).ready(function(e) { $.ajaxSetup({cache:false)}; setInterval(function(){$(#chatlogs).load('lel.php')};); )}; </script> </head> <body> <form name="form1"> Ird be a chat neved: <input type="text" name="uname" /> Az uzeneted : <textarea name="msg"></textarea> <a href="#" onClick="submitChat()">Kuld</a> <div id="chatlogs"> Keressuk az uzeneteket, kerlek varj... </div> </body>
It`s chat. Now, heres what really bothers me. On the 36th line where i wrote : "
$(document).ready(function(e) {
$.ajaxSetup({cache:false)};
setInterval(function(){$(#chatlogs).load('lel.php')};);
)};
" I get something named a SYNTAX ERROR . And I just can`t figure out what the problem is . Can you please help me ?
Look at the selector you're using:
$(#chatlogs)
What is #chatlogs
? Where do you define it? Can JavaScript variables even use a #
character? I doubt they can.
Or, most likely, you probably meant to use that as a jQuery selector string:
$('#chatlogs')
Edit: Also, look at this line:
$.ajaxSetup({cache:false)};
Specifically look at the order in which you open and close your parentheses and braces:
({)}
You need to close containing characters in the stack order in which they were opened, from inner to outer:
({})
thus:
$.ajaxSetup({cache:false});