I’m trying to test some jQuery in this fiddle:
<div id="myDiv"></div>
<input name="Button3" type="button" value="Invoke" onclick="get()">
function get() {
var data = {};
data.foo = "bar";
data.stuff = {
nifty: "stuff"
};
$("#myDiv").text(JSON.stringify(data));
}
The get() function is not being called when I press ‘Invoke’. What should occur is the div content should get updated.
The reason your fiddle doesn’t work is because the settings are wrong. Change
onLoadinthe dropdown on the left tono wrap (head)and it will work.However, as you’re using jQuery for your logic, it’s best practice to use it to attach events too rather than use the clunky
onclickattributes. Try this:Example fiddle