hi i am using jquery version 1.3.2
, i use it because my jquery validation plugin does not work properly with jquery 1.6.2
, but when using version 1.3.2
parseJSON is not a function
appears in firebug . i searched and found the answer that is because
parseJSON was added in version 1.4.1
so what function can i use instead of parseJSON
please help...................
hi i am using jquery version 1.3.2
, i use it because my jquery validation plugin does not work properly with jquery 1.6.2
, but when using version 1.3.2
parseJSON is not a function
appears in firebug . i searched and found the answer that is because
parseJSON was added in version 1.4.1
so what function can i use instead of parseJSON
please help...................
You may use JSON.Parse()
.
var jsontext = '{"firstname":"Jesper","surname":"Aaberg","phone":["555-0100","555-0120"]}';
var contact = JSON.parse(jsontext);
var fullname = contact.surname + ", " + contact.firstname;
You can always eval() JSON http://www.json/js.html Or use one of the existing js libraries to parse JSON. This, for example: https://github./douglascrockford/JSON-js (Yoshi first :-) )
You could add one yourself:
jQuery.parseJSON = function(json) {
if(JSON && typeof JSON.parse === 'function') return JSON.parse(json);
else return eval('(' + json + ')');
};
this will check if there is native JSON support and use that when available, else it will use the eval method (see also here)
Try This ,,
<button onclick="myFunction()">Try it</button>
<script>
function myFunction() {
var obj = JSON.parse('{ "name":"mohsen", "age":26}').myChartZ("myChart3");
document.getElementById("demo").innerHTML.jsonfile = obj.name + ", " + obj.age ;
}