Aumentar el tiempo de carga en ajax
Publicado por Juan Carlos (2 intervenciones) el 08/09/2018 20:08:51
Hola buenas tardes. A ver si alguien por favor puede ayudarme.
Tengo el siguiente js y me gustaría poder ajustar el tiempo que tarda en aparecer y el tiempo que tarda en desaparecer la imagen "loading_carrito.gif" (dicha imagen está en la línea 10 del código).
¿Cómo podría hacerse? Gracias!!
Tengo el siguiente js y me gustaría poder ajustar el tiempo que tarda en aparecer y el tiempo que tarda en desaparecer la imagen "loading_carrito.gif" (dicha imagen está en la línea 10 del código).
¿Cómo podría hacerse? Gracias!!
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<script type="text/javascript">
<!--
function getPages(divid,url)
{
if(divid !="" && url != "")
{
document.getElementById(divid).innerHTML='<img src="loading_carrito.gif">';
var ob= AjaxObject();
var unixTimeStamp= fetch_unix_timestamp();
var nocacheurl = url;
ob.onreadystatechange=function()
{
if(ob.readyState==4)
{
if(ob.status == 200)
{
if(ob.responseText != null)
{
document.getElementById(divid).innerHTML=ob.responseText;
}else
{
alert('There was an error: no data was received');
}
}else
{
alert('Ajax error:' + ob.statusText);
}
}
}
ob.open("GET",nocacheurl,true);
ob.send(null);
}else{
alert('Colocar el id del DIV o el URL en el href en el evento de onClick ');
}
}
function fetch_unix_timestamp()
{
return parseInt(new Date().getTime().toString().substring(0, 10))
}
function AjaxObject()
{
var xmlHttp;
try{
return xmlHttp=new XMLHttpRequest(); // Firefox, Opera 8.0+, Safari
}
catch (e){
try{
return xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); // Internet Explorer
}
catch (e){
try{
return xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e){
alert("Tu navegador no soporta AJAX.");
return false;
}
}
}
}
//-->
</script>
Valora esta pregunta


0