Method for displaying “loading” message

Tags: json ajax jquery
Question!

I am using jquery and the getJSON method and I am wondering if there is a way to display a message saying loading before it loads my content. i know with the jquery ajax calls there is the before submit callbacks where you can have something but the getJSON only has like three options.

Any ideas?

By : Coughlin


Answers

Kent,

Something like that would work, just display a simpling div element with the display text Loading... then display my JSON results.

Ryan

By : Coughlin


Add this somewhere to your page:

<div id="loading" style="display:none">
    <img src="/images/ajax-loader.gif" alt="Loader" />&nbsp;Loading...
</div>
<script type="text/javascript">
    $().ready(function() {
        $("#loading").bind("ajaxSend", function() {
            $(this).show();
        }).bind("ajaxComplete", function() {
            $(this).hide();
        });
    });
</script>

You can style the loader-div as you like, e.g Google Mail-like loader:

#loading
 {
   position:fixed; 
   _position:absolute;
   top: 0;
   left:47%; 
   padding:2px 5px;
   z-index: 5000;
   background-color:#CF4342;
   color:#fff;
 }
By : liggett78


It sounds like you need to use some indirection, via the a grammar rule reference. This can be done with the GrammarBuilder.AppendRuleReference method. It might be easier to test out your grammars first with some SRGS grammar files.

The principle is that you load a main large grammar which has some references in it, to smaller user specific word lists grammars, which you would dynamically load.

See http://www.w3.org/TR/speech-grammar/#S2.2 for the srgs format, and http://msdn.microsoft.com/en-us/library/system.speech.recognition.grammarbuilder.appendrulereference.aspx for the programmatic version.

By : Conor OG


This video can help you solving your question :)
By: admin