snowboardr
Programmer
When should i show a loading icon for ajax, and whats the best method for showing an animated gif when loading?
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
var myAjax = new Ajax.Updater(
target,
url,
{
method: 'get',
parameters: pars,
onComplete:function(request){Element.hide('spinner')},
onLoading:function(request){Element.show('spinner')}
});
var LoadHTMLHttp = null;
function LoadHtml(iCall,sSaveThis,intId) {
// show Loading icon
document.getElementById('Layer1').style.display="";
LoadHTMLHttp = createRequestObject();
var url="ajax_display.asp?call=" + iCall + "&save=" + sSaveThis + "&id=" + intId
LoadHTMLHttp.open('GET', url, true);
LoadHTMLHttp.onreadystatechange = getLoadHTMLHttpResponse;
LoadHTMLHttp.send('');
}
function getLoadHTMLHttpResponse() {
if (LoadHTMLHttp != null)
if (LoadHTMLHttp.readyState == 4)
if (LoadHTMLHttp.status == 200)
document.getElementById('viewsubtopic').innerHTML = LoadHTMLHttp.responseText;
// hide Loading icon document.getElementById('Layer1').style.display="none";
}
var pars = "call=" + iCall + "&save=" + sSaveThis + "&id=" + intId
var myAjax = new Ajax.Updater(
"viewsubtopic",
"ajax_display.asp",
{
method: 'get',
parameters: pars,
onComplete:function(request){Element.hide('Layer1')},
onLoading:function(request){Element.show('Layer1')}
});
Whilst frameworks (like the one you have mentioned twice now) can be very useful in speeding up development time, they tend to require you learn their own data structures and methods... and they usually have quite particular ways of doing things.steven290 said:simplfy your life use prototype
old way
document.getElementById('Layer1')
prototype
$('Layer1')
even further
document.getElementById('Layer1').style.display="";
to
Element.hide('Layer1');
or
Element.toggle('Layer1');