我是 Javascript 和 Ajax 的新手,想弄清楚为什么下面的代码不起作用。
<script type="text/javascript">
$(document).ready(function() {
$('.cadlib').bind('click', function () {
$.get("/models/"+this.id+"/viewmodelinfo/", function(data) {
alert ("yo"); // This line bellow doesn't execute
if (data.fact_type=="T") {
guess_result="This fact is true! " + data.fact_note;
} else {
alert ("yo");
guess_result="This fact is false! " + data.fact_note;
}
$('#result').replaceWith("guess_result");
});
});
});
</script>
这是我的 HTML
<a href = "#mySymbolModal" class = "cadlib" id = "{{symbol.id}}" data-toggle="modal" style = "text-align:center; color: #FF761A;" href="/models/{{symbol.id}}/view_model/"><span id = "modelname"> {{symbol.modelname.upper}}</span> - <span id = "format">{{ symbol.format }}</span><span id = "adder" style="visibility:hidden;">{{symbol.adder}}</span><span id = "adderid" style="visibility:hidden;"> {{symbol.adder.id}}</span><span id = "symbolobject" style="visibility:hidden;">{{symbol}}</span></a>
我认为注释行有问题。我的警报没有实例化。
有什么我遗漏的东西会导致警报不起作用吗?