当前位置:  开发笔记 > 编程语言 > 正文

为什么jQuery.parseJSON不是函数?

如何解决《为什么jQuery.parseJSON不是函数?》经验,为你挑选了3个好方法。

我使用以下jQuery语句,我收到错误,

jQuery.parseJSON不是一个函数

我的功能是,

function Iteratejsondata() {var HfJsonValue = 
      { "Table": [{ "Emp_Id": "3", 
                    "Identity_No": "", 
                    "Emp_Name": "Jerome", 
                    "Address": "Madurai", 
                    "Date_Of_Birth": "", 
                    "Desig_Name": "Supervisior", 
                    "Desig_Description": "Supervisior of the Construction", 
                    "SalaryBasis": "Monthly", 
                    "FixedSalary": "25000.00" }, 
                  { "Emp_Id": "4", 
                    "Identity_No": "", 
                    "Emp_Name": "Mohan", 
                    "Address": "Madurai", 
                    "Date_Of_Birth": "", 
                    "Desig_Name": "Acc ", 
                    "Desig_Description": "Accountant", 
                    "SalaryBasis": "Monthly", 
                    "FixedSalary": "200.00" }, 
                  { "Emp_Id": "5", 
                    "Identity_No": "", 
                    "Emp_Name": "Murugan", 
                    "Address": "Madurai", 
                    "Date_Of_Birth": "", 
                    "Desig_Name": "Mason", 
                    "Desig_Description": "Mason", 
                    "SalaryBasis": "Weekly", 
                    "FixedSalary": "150.00" }, 
                  { "Emp_Id": "6", 
                    "Identity_No": "", 
                    "Emp_Name": "Ram", 
                    "Address": "Madurai", 
                    "Date_Of_Birth": ""
                     "Desig_Name": "Mason", 
                     "Desig_Description": "Mason", 
                     "SalaryBasis": "Weekly", 
                     "FixedSalary": "120.00" }, 
                   { "Emp_Id": "7", 
                     "Identity_No": "", 
                     "Emp_Name": "Raja", 
                     "Address": "Madurai", 
                     "Date_Of_Birth": "", 
                     "Desig_Name": "Mason", 
                     "Desig_Description": "Mason", 
                     "SalaryBasis": "Weekly", 
                     "FixedSalary": "135.00" }, 
                   { "Emp_Id": "8", 
                     "Identity_No": "", 
                     "Emp_Name": "Raja kumar", 
                     "Address": "Madurai", 
                     "Date_Of_Birth": "", 
                     "Desig_Name": "Mason Helper", 
                     "Desig_Description": "Mason Helper", 
                     "SalaryBasis": "Weekly", 
                     "FixedSalary": "105.00" }, 
                   { "Emp_Id": "9", 
                     "Identity_No": "", 
                     "Emp_Name": "Lakshmi", 
                     "Address": "Madurai", 
                     "Date_Of_Birth": "", 
                     "Desig_Name": "Mason Helper", 
                     "Desig_Description": "Mason Helper", 
                     "SalaryBasis": "Weekly", 
                     "FixedSalary": "100.00" }, 
                   { "Emp_Id": "10", 
                     "Identity_No": "", 
                     "Emp_Name": "Palani", 
                     "Address": "Madurai", 
                     "Date_Of_Birth": "", 
                     "Desig_Name": "Carpenter", 
                     "Desig_Description": "Carpenter", 
                     "SalaryBasis": "Weekly", 
                     "FixedSalary": "200.00" }, 
                   { "Emp_Id": "11", 
                     "Identity_No": "", 
                     "Emp_Name": "Annamalai", 
                     "Address": "Madurai", 
                     "Date_Of_Birth": "", 
                     "Desig_Name": "Carpenter", 
                     "Desig_Description": "Carpenter", 
                     "SalaryBasis": "Weekly", 
                     "FixedSalary": "220.00" }, 
                   { "Emp_Id": "12", 
                     "Identity_No": "", 
                     "Emp_Name": "David", 
                     "Address": "Madurai", 
                     "Date_Of_Birth": "", 
                     "Desig_Name": "Steel Fixer", 
                     "Desig_Description": "Steel Fixer", 
                     "SalaryBasis": "Weekly", 
                     "FixedSalary": "220.00" }, 
                   { "Emp_Id": "13", 
                     "Identity_No": "", 
                     "Emp_Name": "Chandru", 
                     "Address": "Madurai", 
                     "Date_Of_Birth": "", 
                     "Desig_Name": "Steel Fixer", 
                     "Desig_Description": "Steel Fixer", 
                     "SalaryBasis": "Weekly", 
                     "FixedSalary": "220.00" }, 
                   { "Emp_Id": "14", 
                     "Identity_No": "", 
                     "Emp_Name": "Mani", 
                     "Address": "Madurai", 
                     "Date_Of_Birth": "", 
                     "Desig_Name": "Steel Helper", 
                     "Desig_Description": "Steel Helper", 
                     "SalaryBasis": "Weekly", 
                     "FixedSalary": "175.00" }, 
                   { "Emp_Id": "15", 
                     "Identity_No": "", 
                     "Emp_Name": "Karthik", 
                     "Address": "Madurai", 
                     "Date_Of_Birth": "", 
                     "Desig_Name": "Wood Fixer", 
                     "Desig_Description": "Wood Fixer", 
                     "SalaryBasis": "Weekly", 
                     "FixedSalary": "195.00" }, 
                   { "Emp_Id": "16", 
                     "Identity_No": "", 
                     "Emp_Name": "Bala", 
                     "Address": "Madurai", 
                     "Date_Of_Birth": "", 
                     "Desig_Name": "Wood Fixer", 
                     "Desig_Description": "Wood Fixer", 
                     "SalaryBasis": "Weekly", 
                     "FixedSalary": "185.00" }, 
                   { "Emp_Id": "17", 
                     "Identity_No": "", 
                     "Emp_Name": "Tamil arasi", 
                     "Address": "Madurai", 
                     "Date_Of_Birth": "", 
                     "Desig_Name": "Wood Helper", 
                     "Desig_Description": "Wood Helper", 
                     "SalaryBasis": "Weekly", 
                     "FixedSalary": "185.00" }, 
                   { "Emp_Id": "18", 
                     "Identity_No": "", 
                     "Emp_Name": "Perumal", 
                     "Address": "Madurai", 
                     "Date_Of_Birth": "", 
                     "Desig_Name": "Cook", 
                     "Desig_Description": "Cook", 
                     "SalaryBasis": "Weekly", 
                     "FixedSalary": "105.00" }, 
                   { "Emp_Id": "19", 
                     "Identity_No": "", 
                     "Emp_Name": "Andiappan", 
                     "Address": "Madurai", 
                     "Date_Of_Birth": "", 
                     "Desig_Name": "Watchman", 
                     "Desig_Description": "Watchman", 
                     "SalaryBasis": "Weekly", 
                     "FixedSalary": "150.00"}]
      };

    //var jsonObj = eval('(' + HfJsonValue + ')');
    var jsonObj = jQuery.parseJSON(HfJsonValue);

我的页面看起来像这样

 
  

我已经通过Firebug进行了检查,看到所有jQuery文件都已下载,但为什么会这样?



1> Yisroel..:

你使用的是什么版本的jQuery?parseJSON在版本1.4.1中添加了,所以如果您使用的是早期版本,那么它就不存在了.



2> Rajat..:

您还可以使用JSON.parse().它原生支持FF,Chrome,Safari和IE8,并且最有可能比JQuery版本更快.

如果你的目标是IE7和IE6,那么JQuery将是最好的选择.



3> Jonathan..:

你使用的是什么版本的jQuery?parseJSON仅适用于1.4.1.

此外,您只能将String传递给函数:http://api.jquery.com/jQuery.parseJSON/

推荐阅读
谢谢巷议
这个屌丝很懒,什么也没留下!
DevBox开发工具箱 | 专业的在线开发工具网站    京公网安备 11010802040832号  |  京ICP备19059560号-6
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有