Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/75.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 错误:使用ajax.get时,元素后应为]标记_Javascript_Jquery_Ajax - Fatal编程技术网

Javascript 错误:使用ajax.get时,元素后应为]标记

Javascript 错误:使用ajax.get时,元素后应为]标记,javascript,jquery,ajax,Javascript,Jquery,Ajax,当我运行在元素列表后显示“SyntaxError:missing]的调试器时,我不断收到一个错误 第一个请求始终按预期工作,但所有后续请求都返回语法错误。谁能给我解释一下我在搞什么。谢谢你 $("#submitmsg").click(function(){ alert('start'); var clientmsg = $("#usermsg").val(); $.post("post.php", {text: clientmsg});

当我运行在元素列表后显示“SyntaxError:missing]的调试器时,我不断收到一个错误

第一个请求始终按预期工作,但所有后续请求都返回语法错误。谁能给我解释一下我在搞什么。谢谢你

$("#submitmsg").click(function(){
    alert('start');      
    var clientmsg = $("#usermsg").val();  
    $.post("post.php", {text: clientmsg});                
    $("#usermsg").attr("value", "");  
    return false;  
}); 
setInterval($.ajax({
        url : 'http:www.whatever.com/log.html',
        type : 'GET', 
            success : function(data)
            {
                document.getElementById('chatframe').innerHTML = data; 
            }
        }), 500);  

</script>
$(“#submitsg”)。单击(函数(){
警报(“启动”);
var clientmsg=$(“#usermsg”).val();
$.post(“post.php”,{text:clientmsg});
$(“#usermsg”).attr(“value”,“value”);
返回false;
}); 
setInterval($.ajax)({
url:'http:www.whater.com/log.html',
键入:“GET”,
成功:功能(数据)
{
document.getElementById('chatframe')。innerHTML=data;
}
}), 500);  

您的设置间隔错误,应该是,
setInterval(func,delay[,param1,param2,…)类似

setInterval(ajax_func, 500);

function ajax_func() {
  $.ajax({
        url : 'http://www.whatever.com/log.html',
        type : 'GET', 
        success : function(data) {
            document.getElementById('chatframe').innerHTML = data; 
        }
  });
}

URL是错误的,每秒进行两次ajax调用似乎不是一个好主意?哦,整个间隔都是错误的,没有函数调用,也没有正确关闭。jQuery不够。你会激怒众神的。替换
document.getElementById('chatframe')。innerHTML=data
$('#chatframe').html(数据)
.attr(“值”…
应该是
.val(“”)