我有一個將數據添加到我的ColdFusion數據庫的AJAX調用。AJAX成功刷新CFDIV
<!---Script to add dashboard link --->
<cfoutput>
<script>
$(function(){
//Add a new note to a link
$("##add_dashboard_links").submit(function(){
// prevent native form submission here
$.ajax({
type: "POST",
data: $('##add_dashboard_links').serialize(),
url: "actionpages/add_dashboard_link.cfm",
beforeSend: function(){
$('.loader').show();
},
complete: function(){
$('.loader').hide(3000);
},
success: function() {
$("##noteDiv").load('templates/dashboard_notes.cfm?techID=#techID#');
$("##addNoteResponse").html('');
$("##link_description").val('');
$("##link_url").val('');
$("##notes").val('');
$("##addNoteResponse").append("Link successfully added.");
}
});
return false;
});
});
</script>
</cfoutput>
我也有結合一些其他內容
<!---Dashboard Links --->
<div id="noteDiv" bind="url:templates/dashboard_notes.cfm">
</div>
這裏是我的模態代碼中找到我的模板頁面上包含這個AJAX腳本引用(這個插件可以在這裏找到的形式CFDIV https://github.com/kylefox/jquery-modal):
<!--- Link to open the modal to add a new dasboard link --->
<div id="DashboardLinks" style="display:none;">
<h3>Add a new dashboard link:</h3>
<form id="add_dashboard_links">
<table width="100%" id="dashboard_table" border="0" cellpadding="5">
<tr>
<td colspan="3"></td>
</tr>
<tr>
<td>Link Description:</td>
<td colspan="2"><input type="text" name="link_description" id="link_description" required="yes" message="Please enter the Link Description"/></td>
</tr>
<tr>
<td>Link URL:</td>
<td colspan="2"><input type="text" name="link_url" id="link_url" required="yes" validate="url" message="Please enter the Link URL with http:// -or- https://"/></td>
</tr>
<tr>
<td>Link Notes:</td>
<td colspan="2"><textarea id="notes" name="notes" cols="" rows=""> </textarea></td>
</tr>
<tr>
<td colspan="3"><input type="submit" name="button" id="button" value="Add Link" />
<input type="hidden" name="link_hidden" value="1"><br />
<div class="loader"><img class="loading-image" src="images/loading.gif" /></div>
<div class="response" id="addNoteResponse"></div>
</td>
</tr>
</table>
</form>
</div>
有沒有辦法一次我收到了AJAX成功刷新此CFDIV標籤?
謝謝。
cfdiv在服務器端執行,其中Ajax請求在客戶端執行。如果你想刷新cfdiv,你必須做出另一個Ajax請求,並在相應的div中重新設置響應。 – 2014-10-31 17:48:41
你想要那個div的新內容是什麼? – 2014-10-31 19:43:33
我正在從cfquery輸出數據。與我的腳本添加到的數據相同。所以我基本上試圖用我新添加的記錄刷新我的cfquery的輸出。 – 2014-10-31 19:59:16