jQuery create new div with ID?

Posted by John on Stack Overflow See other posts from Stack Overflow or by John
Published on 2011-03-15T16:07:09Z Indexed on 2011/03/15 16:10 UTC
Read the original article Hit count: 190

Filed under:
|
|
|
|

Hello,

I have form in my ASP.NET masterPage.master and if i click on submit it call some method from masterPage.master.cs file by ajax (i have it in update panel). But i want improve it with jQuery. So i have this:

$('#submit').click(function () {
            $.ajax({
                type: "POST",
                url: '<% Response.Write("~"+Request.Path); %>',
                beforeSend: function () {
                    $(document.createElement('div')).width($('#formBox').width())
                    .height($('#formBox').height())
                    .css({ backgroundImage: 'url(/Static/Img/bc_overlay.png)', position: 'absolute', left: 0, top: 0, margin: "5px", textAlign: "center", color: "#000", display: "none" })
                    .append("<strong>Nacítám</strong><br /><img src='Static/Img/ajax-loader.gif' width='33px' height='33px' alt='loading' />")
                    .fadeIn("slow")
                    .prependTo($('#formBox'));
                    $('#formBox').css('position', 'relative');
                },
                success: function () {
                }
            });
        });

So if i click on submit, new div is creating (there is loading text and image, and cool opacity overlay), but how i give to this div some ID? Because i need use it in

success: function () {
                    }

i need clear this box and write here some text (error or success).

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about ASP.NET