tags:

views:

1294

answers:

4

Our enterprise app currently uses Json.js I downloaded the JQuery js file, included it in a page that uses json and I started getting Javascript errors in the json.js file. The error is:

Microsoft JScript runtime error: Object doesnt suppor this propety or method

Is this a known issue?

EDIT: I am not sure where this json.js file was downloaded from (a coworker had done this). However, the json.js looks like this:

    json.js
2007-04-13

Public Domain

This file adds these methods to JavaScript:

    array.toJSONString()
    boolean.toJSONString()
    date.toJSONString()
    number.toJSONString()
    object.toJSONString()
    string.toJSONString()

I replaced this file with json2.js and it appears that the new file does not have parseJSON() function. We use this function in several pages.

A: 

I use the json2.js file from http://json.org and the jQuery_1.3.1.js file in combination with no problem.

bendewey
+1  A: 

Looks as though Json.js does use $ as a variable name. In these cases you need to use JQuery's noconflict function. Basically you have to put the JQuery script tag above the Json script tag and call noconflict on jquery before the Json library gets loaded. One nice feature is that, while noconflict make JQuery not use the $, you can assign the results of noconflict (which will be the JQuery object) to another alias, like so

var $j = jQuery.noConflict();

Now you just use $j anywhere you would have used $.

JacobM
+1  A: 

You might want to specify what json.js is. Is this it http://www.json.org/js.html ?

You're probably using an older version that is conflicting with jQuery

This might help: http://www.mail-archive.com/[email protected]/msg06247.html

Luca Matteis
+1  A: 

To solve any variable/method naming issues use this method that worked for me 100% of the time:

(function(){
  // Your javascript function goes here
})();
jQuery Lover