简体   繁体   中英

jQuery AJAX: load HTML into DIV element after click

i would like to load (or be visible) an HTML/ASP.NET email form after the user clicked in a link/button. I have used this code but it doesn't work:

<script type="text/javascript">
    $(document).ready(function () {
        $("#imgMail").click(function (htm) {
            $.get("mailform.html"),
                $("#mailForm").append(htm)); //i have tryed also with .html() function.
        });
    });
</script>

where #imgMail is the ID of the link/button and the #mailForm is the ID of the DIV element into load the content.

How can i resolve this problem? PS The elements are not into a form tag.

Thanks.

Use this..

<script type="text/javascript">
    $(document).ready(function () {
        $("#imgMail").click(function() {
            $.get("mailform.html",function(data){
                $("#mailForm").append(data);
            });
        });
    });
</script>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM