我不想发布有关语法的问题,但这让我发疯。我收到了错误;缺少分号。它指向obj.dataModel:{。
我刚刚开始使用pqgrid,所以请放轻松。
<script type="text/javascript">
$(document).ready(function() {
ListUsers=function(em){
var emid = em.title;
$('#userslistdiv').html('id-' + emid);
$('#userslistdiv').show();
//alert("it worked-" + emid);
var obj = { width:700, height:400, title:"Grid From Array" };
obj.colModel = [{ title: "IndivID", width: 100, dataType: "integer" },
{ title: "Lastname", width: 150, dataType: "string" },
{ title: "Firstname", width: 150, dataType: "float", align: "right" }];
$("#userslistdiv").pqGrid(obj);
obj.dataModel = [
{dataType: "JSON"},
{location: "remote"},
{recIndx: "resourceid"},
{url: "/cfc/basic.cfc?method=getIndivs&EmID=" + emid +"&queryFormat=column"},
{getData: function (response) {
return { data: response.DATA };
}}];
};
});
</script>
答案 0 :(得分:1)
我不久前就开始使用这个工具了,但你可以使用像JSLint或JSHint这样的语法检查器,后者对格式化错误不那么挑剔。可以找到在线版here,您可以找到许多文本编辑器和IDE的插件。
粘贴原始代码确实会产生多个missing semicolon
错误,但原始错误是该工具首先发现的错误:Expected an assignment or function call and instead saw an expression
。