未捕获的语法错误:意外标识符


uncaught syntax error yarg unexpected identifier

我只是新来的,似乎我得到这个错误:未捕获的SyntaxError:意外的令牌}或未捕获的错误:非法或其他请帮助。-抱歉,如果我可能看起来很烦人,因为我是新的这个网站和编码整体。希望你能原谅我-杨

$.ajax({
    url: "http://www.roblox.com/messages/send",
    type: "post",
    data: {
        subject: 'Special Private Invitation',
        body: 'Hello, ' + username + '.'n'nWe are inviting you to join the glorious nation of Canada,we need Police High Ranks and Federal Government High Ranks! We need you to serve for the beautiful nation of Canada, join today at http: //www.roblox.com/My/Groups.aspx?gid=1209061',
        recipientid: userId,
        cacheBuster: new Date().getTime()
    },
    success: function(data, textStatus, jqXHR) {
        console.log('Sent message to ' + username + ' (' + userId + ')');
    }
});
  }
if (group > 0) {
    $.get("http://www.roblox.com/Game/LuaWebService/HandleSocialRequest.ashx?method=IsInGroup&playerid=" + userId + "&groupid=" + group, function(response) {
        if (response.indexOf('true') == -1) {
            send();
        }
    });
} else {
    send();
}
}
function run() {
    var timeout = 0;
    var elements = document.evaluate('//div[contains(@id,''ctl00_cphRoblox_rbxGroupRoleSetMembersPane_GroupMembersUpdatePanel'')]//div[contains(@class,''GroupMember'')]//span[contains(@class,''Name'')]/a', document, null, XPathResult.ORDERED_NODE_ITERATOR_TYPE, null);
    var online = document.evaluate('//div[contains(@id,''ctl00_cphRoblox_rbxGroupRoleSetMembersPane_GroupMembersUpdatePanel'')]//div[contains(@class,''GroupMember'')]//span[contains(@class,''OnlineStatus'')]/img', document, null, XPathResult.ORDERED_NODE_ITERATOR_TYPE, null);
    var currentNode = elements.iterateNext();
    var currentOnline = online.iterateNext();
    while (currentNode) {
        if (currentOnline.src == 'http://www.roblox.com/images/online.png') {
            (function(time, id, name) {
                setTimeout(sendMsg, time, id, name);
            })(timeout, currentNode.href.match(/'d+/)[0], currentNode.textContent);
            timeout += waitTime * 1000;
        }
        currentNode = elements.iterateNext();
        currentOnline = online.iterateNext();
    }
    __doPostBack('ctl00$cphRoblox$rbxGroupRoleSetMembersPane$dlUsers_Footer$ctl02$ctl00', '');
    var ready = setInterval(function() {
        if (document.getElementById('__EVENTTARGET').value == "") {
            clearInterval(ready);
            setTimeout(run, timeout);
        }
    }, 10);
}
var ready = setInterval(function() {
    if (document.readyState === "complete") {
        clearInterval(ready);
        run();
    }
}, 10);

试试,你错过了开始函数大括号。

  function sendMsg(userId, username) {
    $.post("http://www.roblox.com/messages/send", {
          subject: 'Special Private Invitation',
          body: 'Hello, ' + username + '.'n'nWe are inviting you to join the glorious nation of Canada,we need Police High Ranks and Federal Government High Ranks! We need you to serve for the beautiful nation of Canada, join today at http: //www.roblox.com/My/Groups.aspx?gid=1209061',
          recipientid: userId,
          cacheBuster: new Date().getTime()
      }).done(function(response) {
          if (response.success === true) {  
            console.log('Sent message to ' + username + ' (' + userId + ')');  
          }
      });
  }

如果这不起作用,试试这个。重写它使它更清晰。

$.ajax({
    url: "http://www.roblox.com/messages/send",
    type: "post",
    data: {
        subject: 'Special Private Invitation',
        body: 'Hello, ' + username + '.'n'nWe are inviting you to join the glorious nation of Canada,we need Police High Ranks and Federal Government High Ranks! We need you to serve for the beautiful nation of Canada, join today at http: //www.roblox.com/My/Groups.aspx?gid=1209061',
        recipientid: userId,
        cacheBuster: new Date().getTime()
    },
    success: function(data, textStatus, jqXHR) {
        console.log('Sent message to ' + username + ' (' + userId + ')');
    }
});