jQuery bind and getJSON combo not behaving as expected
I am loading a jQuery UI dialog and at the end of the HTML that I get with an AJAX call is the script below. I expect it to bind to a bu开发者_运维知识库tton that I have defined and to run when clicked, however it does not run. If I change the contents of the function to nothing but an alert it runs fine. JSLint has not helped me to find my problem. Can anyone tell me what I am missing?
<script type="text/javascript">
$("#runbutton").bind("click",function()
{
$("#loading").show();
$.getJSON("web.air.sum.rpt.php","json=true&whse="+$("#whse").val()+"&date1="+$("#date1").val()+"&date2="+$("#date2").val()+"&status="+$("#status").val()+"&caby="+$("#caby").val()+"&catarg="+$("#catarg").val(),function(data, textStatus)
{
$("#results").html("<table width='100%' id='restbl'></table>");
$("#loading").hide();
$.each(data,function(key,val)
{
$("#restbl")
.append("<tr><th>AIR "+val.KEY+"</th><td>"+val.ACCDATE+" "+val.ACCTIME+"</td></tr>")
.append("<tr><th>Team Member</th><td>"+val.NAME+"</td></tr>");
.append("<tr><th>Target</th><td>"+val.TARDATE+"</td></tr>");
.append("<tr><th>Accident Description</th></tr><tr><td colspan='2'>"+val.ACCDESC+"</td></tr>");
.append("<tr><th>Corrective Action</th></tr><tr><td colspan='2'>"+val.CORRACT+"</td></tr>");
.append("<tr><td></td><td>By "+val.VERBY+"</td></tr>");
.append("<tr><td colspan='2'><hr></td></tr>");
});
});
});
</script>
You have semicolons after your .append() functions. This should only be so after the last one.
精彩评论