开发者

JQuery: SyntaxError: missing ) in parenthetical

I have seen the other jquery post about this syntax error. But i really cannot find the error for this.

var projects = new Object();

$("#project_"+projectId+" .todo_input").each(function(){
    if($(this).attr('disabled') == false){
        id = $(this).attr('id')
        val = $(this).val();
        pos = id.indexOf('_', 6);
        projectId = id.substr(6, pos - 6);
        taskId = id.substr(pos + 1);

        if(projects[projectId] == undefined)
            projects[projectId] = new Object();

        if(projects[projectId][taskId] == undefined)
            projects[projectId][taskId] = val;
    }
});

var today = new Date();


var w = $(document).getUrlParam("week");
var y = $(document).getUrlParam("year");

if(w == undefined){
    w = today.getWeek();
}
if(y == undefined)
    y = today.getFullYear();

$.post("./", {
    controller: "project",
    action: "sendInTodoLoggin",
    data: projects,
    week: w,
    year: y
}, function(data) {
    try{
        dat = eval('(' + data + ')');
    }catch(err){
        alert("开发者_JS百科Error: " + data);
        return;
    }

    if(dat == 1){
        setTimeout("end('"+projectId+"')", 1000);
    }else{
        $("#loadImg").hide();
        alert('Error');
    }
});


stopped reading at line 5:

missing ;


This is one reason why I don't like the convention of writing the opening brace '{' to the right of the 'if', 'for', etc., statements. It just makes things confusing and I don't know the reason behind liking this kind of antisymmetry! The braces in:

if (...)
{
    if (...)
    {
        if (...)
        {
        }
    }
}

is definitely easier to match than:

if (...) {
    if (...) {
        if (...) {
        }
    }
}

Anyway, as a good rule to solve braces problem, the first thing would be to use a Find-Replace to count the number of opening and closing braces and whether they match or not. If they don't, you can use any good editor (that highlights the matching brackets when you put the cursor over a bracket) and search for '(' and '{' and see whether the matching bracket highlighted is the one you intended or not.


Is your data being returned from the post action not well formed?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜