當我運行這個腳本時,我得到AjaxFunction is undefined
。我已經搜索並知道它沒有在適當的範圍內定義,但任何人都可以讓我知道什麼是定義它的正確方法,以及錯誤的原因是什麼。如何通過ajax和jquery在冷聚變中加載頁面?
<script type=」text/javascript」>
function(AjaxFunction) {
alert(「test」);
$.ajax({
type: 「GET」,
url: 「cfquery.cfm」,
success: function (res) {
alert(res);
document.getElementById("loadingdiv").style.display = 」block」;
document.getElementById("loadingdiv").innerHTML = res;
}
});
};
</script>
<cfform id="PageloadAjax" name="PageloadAjax">
<div id="Displayingdiv" name="displayingdiv">
<cfinput id="CFQUERYbutton" name="CFQUERYbutton" type="button" value="Displaypage" onclick="AjaxFunction">
</div>
<div id="loadingdiv" name="loadingdiv"></div>
</cfform>
'函數(AjaxFunction){'應'函數AjaxFunction(){'和'的onclick = 「AjaxFunction」'應該是'的onclick = 「AjaxFunction()」' - 或更好的是一個不顯眼的事件處理程序。還要注意,你的一些雙引號是無效的。使用'''''''',而不是''' –