意外的令牌}找不到错误

时间:2013-11-11 17:11:56

标签: javascript

我尝试了所有的东西,但我不知道错误应该在哪里,它显示我一个未使用的标记}在一条线上,我甚至没有这个标志。

<script type="text/javascript">
function postToStatus(action,type,user,ta){
var data = _(ta).value;
if(data == ""){
    alert("Type something first weenis");
    return false;
}
_("statusBtn").disabled = true;
var ajax = ajaxObj("POST", "php_parsers/qp_system.php");
ajax.onreadystatechange = function() {
    if(ajaxReturn(ajax) == true) {
        var datArray = ajax.responseText.split("|");
        if(datArray[0] == "post_ok"){
                var sid = datArray[1];
                data = data.replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/\n/g," ><br />").replace(/\r/g,"<br />");
                var currentHTML = _("statusarea").innerHTML;
                _("statusarea").innerHTML = '<div id="status_'+sid+
                'class="status_boxes"><div><b>Posted by you just now:</b><span >id="sdb_'+sid+
                '"><a href="#" onclick="return false" >onmousedown="deleteStatus("'+sid+
                '\',\'status_'+sid+
                '\');" title="DELETE THIS STATUS AND ITS REPLIES">delete status</a>    ></span><br />'+data+
                '</div></div>"'+currentHTML;
                _("statusBtn").disabled = false;
                _(ta).value = "";
        } else {
                alert(ajax.responseText);
        }
    }
}
ajax.send("action="+action+"&type="+type+"&user="+user+"&data="+data);
}

1 个答案:

答案 0 :(得分:2)

你需要在ajax.send()调用之前的最后一个之后放一个分号。

如果你写JavaScript,这个网站是你最好的朋友:http://closure-compiler.appspot.com/home

function postToStatus(action, type, user, ta) {
  var data = _(ta).value;
  if (data == "") {
    alert("Type something first weenis");
    return false;
  }
  _("statusBtn").disabled = true;
  var ajax = ajaxObj("POST", "php_parsers/qp_system.php");
  ajax.onreadystatechange = function() {
    if (ajaxReturn(ajax) == true) {
      var datArray = ajax.responseText.split("|");
      if (datArray[0] == "post_ok") {
        var sid = datArray[1];
        data = data.replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/\n/g, " ><br />").replace(/\r/g, "<br />");
        var currentHTML = _("statusarea").innerHTML;
        _("statusarea").innerHTML = '<div id="status_' + sid + 'class="status_boxes"><div><b>Posted by you just now:</b><span >id="sdb_' + sid + '"><a href="#" onclick="return false" >onmousedown="deleteStatus("' + sid + "','status_" + sid + '\');" title="DELETE THIS STATUS AND ITS REPLIES">delete status</a>    ></span><br />' + data + '</div></div>"' + currentHTML;
        _("statusBtn").disabled = false;
        _(ta).value = "";
      } else {
        alert(ajax.responseText);
      }
    }
  };
  ajax.send("action=" + action + "&type=" + type + "&user=" + user + "&data=" + data);
}
;