Luis
Luis

Reputation: 3277

Has no method parseJSON with jquery

This is my code:

$(document).ready(function(){
        $('.filter_users').live('click', function() {
            var obj = jQuery.parseJSON('{"name":"John"}');
            alert( obj.name === "John" );
        });
});

In the moment I'm clicking the class filter_users (It's a simple checkbox..) It shows me an error:

Uncaught TypeError: Object function (E,F){return new o.fn.init(E,F)} has no method 'parseJSON'

Why does it happen? The jQuery file is from here - http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js

Other jQuery elements work well.

Upvotes: 0

Views: 4433

Answers (1)

Shadow Wizard
Shadow Wizard

Reputation: 66388

The .parseJSON was added to jQuery only at version 1.4.1 so it means you probably use older version.

Good chance that you include both old version and new version, and since the old version is included later it "overrides" the new version.

Include only the new version and it will work.

Upvotes: 5

Related Questions