【问题标题】:unexpected token in succes row [closed]成功行中的意外令牌[关闭]
【发布时间】:2014-12-10 11:21:25
【问题描述】:
// make AJAX call to get contents and display in DIV1 and DIV2
function ajaxRequest(div_id1, div_id2, request_url, request_params) {
    $("#" + div_id1).html('<img src="images/loading.gif" alt="Loading" title="Loading"/>');
    $.ajax({
        type: "POST",
        dataType: "html",
        url: request_url,
        data: request_params,
        success: function (response) {
            $("#" + div_id1).html('<br>' + response.substring(0, 1); 
            $("#" + div_id2).html(response.substring(1, 2);
        },
        error: function (req, errorMsg) {}
    })
}

【问题讨论】:

  • 问题是什么
  • 您的 html 方法缺少右括号。
  • html(response.substring(1, 2)
  • 只需检查 ajax 成功回调中的右括号。

标签: php jquery


【解决方案1】:

你忘了再添加 1 个右括号

 $("#" + div_id1).html('<br>' + response.substring(0, 1));
 $("#" + div_id2).html(response.substring(1, 2));

【讨论】:

    【解决方案2】:

    你有一些错别字:

    $("#" + div_id1).html('<br>' + response.substring(0, 1)); 
    $("#" + div_id2).html(response.substring(1, 2));
    

    添加)关闭.html()

    【讨论】:

      【解决方案3】:

      html() 后缺少右括号

      success: function (response) {
          $("#" + div_id1).html('<br>' + response.substring(0, 1)); 
          //                                                     ^^
          $("#" + div_id2).html(response.substring(1, 2));
          //                                            ^^
      },
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-08-20
        • 2018-06-07
        • 1970-01-01
        • 2017-04-29
        • 1970-01-01
        相关资源
        最近更新 更多