I'm trying the following:
var objJson = jQuery.parseJSON('"myFunc": function(){ ... }');
This fails. Now my question(s): Why does it fail and how can I achieve what I'm trying?
Thank you in advance!
I'm trying the following:
var objJson = jQuery.parseJSON('"myFunc": function(){ ... }');
This fails. Now my question(s): Why does it fail and how can I achieve what I'm trying?
Thank you in advance!
You seem to have a misconception about what JSON is. JSON is a simple data format with a syntax that resembles JavaScript objects. It's so simple that spec fits a single page. If you have functions it it, it isn't JSON. Thus there is no point in using JSON tools.
Now, the usual way to inject external JavaScript code into an HTML document is the <script>
tag:
<script type="text/javascript" src="/path/to/code.js">
ok, the following worked for me (should have googled a bit longer):
var o = eval('(' + '"myFunc": function(){ ... }' + ')')