小编Sea*_*yne的帖子

在AJAX成功后附加DIV

正如标题所述,我正在尝试执行一个简单的任务,当我的ajax帖子成功完成数据库查询时,我想使用AJAX成功选项将"Success"添加到空DIV中.我无法弄清楚如何让文字出现.任何帮助表示赞赏.谢谢.

这是我工作的AJAX帖子:

<script>
    $(function(){
        $("#noteForm").submit(function(){
            // prevent native form submission here
            $.ajax({
                type: "POST",
                data: $('#noteForm').serialize(),
                dataType: 'json',
                url: "actionpages/link_notes_action.cfm?id=2",
                success: function() {
                    $(".response").append($( "Success" ) );
                }    
            });
            return false;           
        });
    });
</script>
Run Code Online (Sandbox Code Playgroud)

我的页面中有一个div,其id为"response",嵌套在我的表单的div中.

<!--- Modal HTML embedded directly into document --->
<div id="LinkNotes#id#" style="display:none;">
    <p>These are the notes for: #link_description#</p>
    <form id="noteForm">
        <textarea id="noteText" name="noteText" cols="45" rows="10">#notes#</textarea><br />

        <input name="submit" id="submitForm" type="submit" value="Update"><div class="response" id="response"></div>
        <input type="hidden" name="hidden" value="#get_dashboard_links.ID#">
    </form>
</div>
Run Code Online (Sandbox Code Playgroud)

javascript

1
推荐指数
1
解决办法
2076
查看次数

标签 统计

javascript ×1