预期}找到成功错误

时间:2013-02-14 20:06:29

标签: javascript jquery ajax

myClickHandler = function(e) {
       var ng = $('#num_groups').val();
       for (var group = 1; group <= ng; group++) {
         if (!validation(group)) return false;
       }
       if (confirm( "Are you sure you want to Proceed?" + "\n")) {
         $.ajax({
           url: "insertpenaltymarks.php",
           data: $("#PenaltyMarks").serialize(),
           async: false,
           type: "POST"
           success:function(result){
            $.ajax({
                 url: "sessioncomplete.php",
                 async: false,
                 type: "POST",
                 success:function(response){
                      window.location = "complete.php";
                  }
               });
        }
         });
         return true;
      } else {
        return false;
      }
    }

使用上面的代码,我尝试发送2个a​​jax请求,一个转到insertpenaltymarks.php页面,另一个转到sessioncomplete.phpcomplete.php页面。但我收到的错误我真的不太明白:

Syntax error at line 57 while loading: expected '}', got 'success'
           success:function(res

这个错误究竟意味着什么,以及如何修复?

2 个答案:

答案 0 :(得分:4)

在第一个Ajax调用中的"POST"之后设置逗号:

// ---------v
type: "POST",
success: function(result) {

答案 1 :(得分:0)

"POST"后需要逗号。