I’ve implemented a simple JQuery.GetJSON method on the click of an <img> tag. The problem is that Internet explorer is throwing exception that methodname is undefined.
Can anybody guide me on this.
HTML:
<div class="itemgenerate">
<img src="/images/generate.png" onclick="sendJSONRequest()" style="cursor: pointer;" />
</div>
<div id="divTarget" class="itemtext">
<p id="pStuff"></p>
</div>
Java Script:
<script language="javascript" type="text/javascript" src="/Scripts/jquery-1.4.1.js" />
<script language="javascript" type="text/javascript">
function sendJSONRequest() {
$.getJSON("/Home/Generate", $('#text1').val(), function (data) {
$('#pStuff').text(data.Stuff);
});
}
</script>
Please if anybody can explain me what is wrong here:
scripttags can’t be self-closing. You need a closingscripttag:Your current syntax means the first script tag won’t be closed and its content will be treated as part of the first. Since the first tag has a
srcattribute, its content will be ignored, so your function won’t be defined.