目前引入脚本
<script src="js/jquery-1.8.0.min.js" type="text/javascript"></script> <script src="js/linq.js" type="text/javascript"></script> <script> $(function () { TestQueryObjects(); }); function TestQueryObjects() { var jsonArray = [ { "StuID": 1, "StuName": "James", "Age": 30, "Country": "USA" }, { "StuID": 2, "StuName": "Byant", "Age": 36, "Country": "USA" }, { "StuID": 3, "StuName": "Lin", "Age": 30, "Country": "Taiwan" }, { "StuID": 4, "StuName": "Yao", "Age": 30, "Country": "Shanghai" } ]; var querResult = $.Enumerable.From(jsonArray) .Where(function (x) { return x.Age <= 30; }) .OrderBy(function (x) { return x.StuID; }) .ToArray() .forEach(function (i) { document.write(i.StuID + ";" + i.StuName + ";" + i.Age + ";" + i.Country + "<br/>"); }); document.write("====================================" + "<br/>"); var queryResult2 = $.Enumerable.From(jsonArray) .Where("$.Age<=30") //这个操作很牛气 .OrderBy("$.StuID") .ToArray() .forEach(function (i) { document.write(i.StuID + ";" + i.StuName + ";" + i.Age + ";" + i.Country + "<br/>"); }); } </script>
老是报错
错误: '$.Enumerable' 为空或不是对象
不知道改如何配置,请大神指点,在线等,挺急!!!!!!!!!
jquery呢?
那必须的,还用问么
换个最新版的或者浏览器试下
引用错了js文件 linq.js不是在jquery框架下使用的,应该引用jquery.linq.js文件