获取错误SyntaxError:预期的表达式,在Firefox中为'}'

时间:2018-11-28 14:02:02

标签: javascript html

我正在尝试创建动态html td,如下所示:

var id = "testId";
var issueId = "testIssueId";

var sourceRow = ($(this).find("OBJECTID").text() === "") ? '<td></td>' : "<td><img src='contactImages/attachmentImage.png' onclick='issueAttachmentAttachmentLookUp('"+id+"','"+issueId+"')'> </img></td>" ;

单击上面的td(在Firefox中)时,出现以下错误:

  

SyntaxError:期望的表达式,得到了'}'

函数是:

function issueAttachmentAttachmentLookUp(strIssueID, issueID1)
{
    var aryArgument = new Array();

    aryArgument[0] = m_stateData;
    aryArgument[1] = g_ContactSoapWebServiceURL;
    aryArgument[2] = g_PQContactTree;
    aryArgument[3] = strIssueID;
    aryArgument[4] = m_PQClientConfig;
    aryArgument[5] = g_BAList;
    aryArgument[6] = g_references;
    aryArgument[7] = ResponseNode;
    aryArgument[8] = issueCurrentBA;
    aryArgument[9] = issueID1;

    ModalHelper.showModalDialog(
        'PQCaseAttachment.htm',
        'Issue Attachments',
        890,
        700,
        aryArgument,
        function(refreshWindow)
        {
            if(refreshWindow){
                refresh();
            }
        }
    );
}

我怀疑onclick事件语法有问题,但无法识别问题。

有人有什么线索吗?

2 个答案:

答案 0 :(得分:1)

您遇到语法错误。您的第二行应该是:

var issueId = "testIssueId";

答案 1 :(得分:0)

单引号过多。您的SELECT bt.CompanyName, COUNT(CASE WHEN bt.AcceptedAt IS NOT NULL THEN bt.UCId END) AS AcceptedCount, COUNT(CASE WHEN bt.DoneStatus IN (1,6) THEN bt.UCId END) AS CompletedCount, COUNT(CASE WHEN bt.DoneStatus IN (4) THEN bt.UCId END) AS SkippedCount, COUNT(bt.UCId) AS TotalCount FROM ( SELECT uic.*, uic.Id AS UCId, ic.*, ic.Id AS CompanyId, ic.Name AS CompanyName FROM UserChallenges iuc JOIN Users iu ON iuc.UserId = iu.Id JOIN Companies ic ON ic.Id = iu.CompanyId) bt GROUP BY bt.CompanyId, bt.CompanyName 如下所示:

onclick

看看有没有多余的单引号?将这些替换为onclick内的onclick='issueAttachmentAttachmentLookUp('id','issueId')' ^ ^ ^ ^ ^ ^

\"