Javascript分析错误

Javascript分析错误,javascript,jquery,ajax,post,Javascript,Jquery,Ajax,Post,我正在使用jQuery执行一个AJAX POST请求。这是密码 jQuery(document).ready(function() { jQuery('#tweets').load('/index.php?app=ccs&module=pages&section=pages&id=6'); var refreshId = setInterval(function() { jQuery('#tweets').load('/index.php?app=ccs&a

我正在使用jQuery执行一个AJAX POST请求。这是密码

jQuery(document).ready(function() {
     jQuery('#tweets').load('/index.php?app=ccs&module=pages&section=pages&id=6');
var refreshId = setInterval(function() {
  jQuery('#tweets').load('/index.php?app=ccs&module=pages&section=pages&id=6');
}, 30000);
});
jQuery(function() {  
jQuery(".button").click(function() {
var dataString = 'tweet='+ tweet;
//alert (dataString);return false;
$.ajax({
type: "POST",
url: "/index.php?app=ccs&module=pages&section=pages&id=7",
data: dataString,
success: function() {
    $('#postsuccess').html("<b>Post Successful</b>");
  }); // this is where the parse error is
}
});
return false;
});  
});
jQuery(文档).ready(函数(){
jQuery('#tweets').load('/index.php?app=ccs&module=pages§ion=pages&id=6');
var refreshId=setInterval(函数(){
jQuery('#tweets').load('/index.php?app=ccs&module=pages§ion=pages&id=6');
}, 30000);
});
jQuery(函数(){
jQuery(“.button”)。单击(函数(){
var dataString='tweet='+tweet;
//警报(数据字符串);返回false;
$.ajax({
类型:“POST”,
url:“/index.php?app=ccs&module=pages§ion=pages&id=7”,
数据:dataString,
成功:函数(){
$('#postsucture').html(“Post Successful”);
});//这就是解析错误所在
}
});
返回false;
});  
});

有什么想法吗?

这就是为什么格式化代码很重要的原因

jQuery(document).ready(function() {
    jQuery('#tweets').load('/index.php?app=ccs&module=pages&section=pages&id=6');
    var refreshId = setInterval(function() {
        jQuery('#tweets').load('/index.php?app=ccs&module=pages&section=pages&id=6');
    },
    30000);
});
jQuery(function() {
    jQuery(".button").click(function() {
        var dataString = 'tweet=' + tweet;
        //alert (dataString);return false;
        $.ajax({
            type: "POST",
            url: "/index.php?app=ccs&module=pages&section=pages&id=7",
            data: dataString,
            success: function() {
                $('#postsuccess').html("<b>Post Successful</b>");
            }
        });
        return false; // This is also bad placed
    });
});
您的
$.ajax
方法应该是

url: "/index.php",
data: { app: 'css', module: 'pages', section: 'pages', id: 7, tweets: tweet },

这就是为什么格式化代码很重要的原因

jQuery(document).ready(function() {
    jQuery('#tweets').load('/index.php?app=ccs&module=pages&section=pages&id=6');
    var refreshId = setInterval(function() {
        jQuery('#tweets').load('/index.php?app=ccs&module=pages&section=pages&id=6');
    },
    30000);
});
jQuery(function() {
    jQuery(".button").click(function() {
        var dataString = 'tweet=' + tweet;
        //alert (dataString);return false;
        $.ajax({
            type: "POST",
            url: "/index.php?app=ccs&module=pages&section=pages&id=7",
            data: dataString,
            success: function() {
                $('#postsuccess').html("<b>Post Successful</b>");
            }
        });
        return false; // This is also bad placed
    });
});
您的
$.ajax
方法应该是

url: "/index.php",
data: { app: 'css', module: 'pages', section: 'pages', id: 7, tweets: tweet },
试试这个:

jQuery(document).ready(function() {
    jQuery('#tweets').load('/index.php?app=ccs&module=pages&section=pages&id=6');
    var refreshId = setInterval(function() {
        jQuery('#tweets').load('/index.php?app=ccs&module=pages&section=pages&id=6');
    }, 30000);
});
jQuery(function() {
    jQuery(".button").click(function() {
        var dataString = 'tweet=' + tweet;
        //alert (dataString);return false;
        $.ajax({
            type: "POST",
            url: "/index.php?app=ccs&module=pages&section=pages&id=7",
            data: dataString,
            success: function() {
                $('#postsuccess').html("<b>Post Successful</b>");
            } // this is where the parse error is
        });
    });
    return false;
});
jQuery(文档).ready(函数(){
jQuery('#tweets').load('/index.php?app=ccs&module=pages§ion=pages&id=6');
var refreshId=setInterval(函数(){
jQuery('#tweets').load('/index.php?app=ccs&module=pages§ion=pages&id=6');
}, 30000);
});
jQuery(函数(){
jQuery(“.button”)。单击(函数(){
var dataString='tweet='+tweet;
//警报(数据字符串);返回false;
$.ajax({
类型:“POST”,
url:“/index.php?app=ccs&module=pages§ion=pages&id=7”,
数据:dataString,
成功:函数(){
$('#postsucture').html(“Post Successful”);
}//这就是解析错误所在的位置
});
});
返回false;
});
像jsfiddle.net这样的网站使缩进变得容易。

试试以下方法:

jQuery(document).ready(function() {
    jQuery('#tweets').load('/index.php?app=ccs&module=pages&section=pages&id=6');
    var refreshId = setInterval(function() {
        jQuery('#tweets').load('/index.php?app=ccs&module=pages&section=pages&id=6');
    }, 30000);
});
jQuery(function() {
    jQuery(".button").click(function() {
        var dataString = 'tweet=' + tweet;
        //alert (dataString);return false;
        $.ajax({
            type: "POST",
            url: "/index.php?app=ccs&module=pages&section=pages&id=7",
            data: dataString,
            success: function() {
                $('#postsuccess').html("<b>Post Successful</b>");
            } // this is where the parse error is
        });
    });
    return false;
});
jQuery(文档).ready(函数(){
jQuery('#tweets').load('/index.php?app=ccs&module=pages§ion=pages&id=6');
var refreshId=setInterval(函数(){
jQuery('#tweets').load('/index.php?app=ccs&module=pages§ion=pages&id=6');
}, 30000);
});
jQuery(函数(){
jQuery(“.button”)。单击(函数(){
var dataString='tweet='+tweet;
//警报(数据字符串);返回false;
$.ajax({
类型:“POST”,
url:“/index.php?app=ccs&module=pages§ion=pages&id=7”,
数据:dataString,
成功:函数(){
$('#postsucture').html(“Post Successful”);
}//这就是解析错误所在的位置
});
});
返回false;
});

站点如jsFIDL.NET使缩进变得容易。

如果@ BalExand是正确的,你应该考虑添加一个带有JSLLT的编辑器,这将检查你的代码。如果@ BalExand是正确的,你应该考虑添加一个JSLLT编辑器,这将检查你的代码。+ 1,现在大多数文本编辑器都有一个很好的,易于使用的缩进特征,如果没有其他问题,只需按tab键或空格键几次。我删除了我的答案,你抢先了我一步=D+1,现在大多数文本编辑器都内置了一个很好的、易于使用的缩进功能,如果没有其他功能的话,只需按tab或space几次。我删除了我的答案,你比我快=D