我正在使用AJAX从我的网页调用servlet。到目前为止,到目前为止,我已经添加了一些代码来显示Servlet工作时的加载屏幕,但这仅在第一次运行时有效,此后,调用了Servlet,我可以更改光标,但等待屏幕不工作>
CSS
#loading {
width: 100%;
height: 100%;
position: fixed;
top: 0;
left: 0;
opacity: 0.75;
background-color: #ffffff;
-webkit-transition: all .5s ease;
z-index: 3000;
display:none;
vertical-align: middle;
text-align: center;
}
#loading-img {
border: 16px solid #f3f3f3;
border-radius: 50%;
border-top: 16px solid #297bda;
width: 50px;
height: 50px;
margin: auto;
-webkit-animation: spin 2s linear infinite; /* Safari */
animation: spin 2s linear infinite;
position: absolute;
top: 50%; left: 50%;
transform: translate(-50%,-50%);
padding: 2rem;
}
HTML
<div id="loading">
<div id="loading-img"></div>
</div>
JavaScript
$('#compare').click(function() {
//just the relevant part
$('#loading').show();
....
});
我打电话给
$('#loading').hide();
.done(函数(数据)。
正如我所说,代码已执行,但加载屏幕仅是第一次加载。实际上,在第二次尝试解析加载div时,我收到了null。 我也尝试过
document.getElementById("loading").style.visibility = "hidden";
document.getElementById("loading").style.display = "none";
代替使用hide()但结果相同。
有什么主意吗?
答案 0 :(得分:0)
找到了!下班后,这是我的愚蠢错误。 我知道了
procedure TForm2.B_ConnectClick(Sender: TObject);
var vIdSocketHandle: TIdSocketHandle;
vLocalAddressList: TIdStackLocalAddressList;
vI: Integer;
vSendLIST: TStringLIST;
begin
if IdUDPServer.Active then
begin
Timer.Enabled := False;
IdUDPServer.Active := False;
B_Connect.Text := 'Connect';
M_Networks.Lines.Clear;
M_Debug.Lines.Clear;
LB_Peers.Items.Clear;
end
else
begin
try
vSendLIST := TStringLIST.Create;
IdUDPServer.Bindings.Clear;
vLocalAddressList := TIdStackLocalAddressList.Create;
GStack.GetLocalAddressList(vLocalAddressList);
M_Networks.Lines.Clear;
for vI := 0 to vLocalAddressList.Count-1 do
begin
if vLocalAddressList.Addresses[vI].IPVersion = id_IPV4 then
begin
M_Networks.Lines.Add(vLocalAddressList.Addresses[vI].IPAddress);
vSendLIST.Add(Format('LOCALIP,%s:%d',[vLocalAddressList.Addresses[vI].IPAddress,E_ClientPort.Text.ToInteger]));
end;
end;
vIdSocketHandle := IdUDPServer.Bindings.Add;
vIdSocketHandle.Port := E_ClientPort.Text.ToInteger;
vIdSocketHandle.IP := '0.0.0.0';
IdUDPServer.Active := True;
for vI := 0 to vSendLIST.Count-1 do
IdUDPServer.Send(E_Server.Text, E_Port.Text.ToInteger, vSendLIST[vI]);
B_Connect.Text := 'Disconnect';
if Assigned(vSendLIST) then FreeAndNil(vSendLIST);
finally
if Assigned(vLocalAddressList) then FreeAndnil(vLocalAddressList);
end;
end;
end;
并且在做 document.getElementById(“ finalresults”)。innerHTML =“”; 在ajax调用期间,由于我忘记了上一个div中的/,所以我删除了加载div
感谢大家,对此错误表示歉意