Welcome to my website. I am always posting links to photo albums, art, technology and other creations. Everything that you will see on my numerous personal sites is powered by the formVistaTM Website Management Engine.

icon.linkedin.jpgicon.twitter.jpg

  • Syntax for Dynamically Generating JSON in JavaScript to be Output to HTML
    04/11/2012 4:50PM

    Should you find yourself in a situation where you want to call a function (or method) that accepts JSON data parameters that you want to actually print to the browser to be invoked on some sort of callback (onchange, onclick, etc).

    Given the following function:

    doSomething(JSONparam) {
        // Something happens in here . . .
    }

    Here is the syntax for rendering an onclick link that is generated in JavaScript and then output to the DOM:

    var $markup = '<a href="some/url.html" onclick="doSomething({\'key1\':\'value'\, \'key2\':\'value\'}); return false;">Some link</a>';

Advanced Search

Categories

Archives