jQuery的创建新的分区ID为?分区、jQuery、ID

2023-09-10 21:34:22 作者:半颗糖丶甜到蛀牙

我在ASP.NET masterPage.master有形式,如果我点击提交,呼吁从masterPage.master.cs文件通过AJAX一些方法(我有它的更新面板)。但我想用jQuery改善。所以,我有这样的:

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>Načí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 () {
                }
            });
        });

所以,如果我点击提交,新的div正在创造(有加载的文字和图片,和冷静不透明覆盖),但我如何给该div一些ID?,因为我需要用它在

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).

推荐答案

刚刚成立,当你创建它的属性。

Just set the attribute when you're creating it

$(document.createElement('div')).attr('id', 'theID')//rest of code