0

i have this jquery code

else if ($(this).val() === "5") {
        var codefaqs = $(this).val();
        $('#imgloadfaqs').show();
        $("#faqsmain").attr("disabled", "disabled");
        $('#faqsanswer').load('http://royta.org/somefolder/get.php',{codedgive:codefaqs},function(applycode){
            $('#faqsanswer').html(applycode);
            $('#imgloadfaqs').hide(2000);
            $("#faqsmain").removeAttr("disabled");
        });
    }

and show loading image and disable select box
i want when get.php do its work and done to send resault
loading image gone
but with this code its gone very soon before php show resault
can anyone help me with this?

3 Answers 3

2

move hide method inside function where you are getting result from php file as :

...,codedgive:codefaqs},function(applycode){
            $('#faqsanswer').html(applycode);
            $("#faqsmain").removeAttr("disabled");
            $('#imgloadfaqs').hide(500);
        });
Sign up to request clarification or add additional context in comments.

3 Comments

not work ....! actutty i dont need $('#faqsanswer').html(applycode); its load in $('#faqsanswer').load('htt') i remove $('#faqsanswer').html(applycode); this line
@masiharastooyi : you will need to move hide image logic after code where u are getting result back from server
$('#faqsanswer').load('....ler/get.php',{codedgive:codefaqs},function(applycode){ $('#faqsanswer').html(applycode); $('#imgloadfaqs').hide(2000); $("#faqsmain").removeAttr("disabled"); }); but not work its gone very soon yet
2

try putting the code that hides the image inside the done function. I believe this would be the right approach:

$('#faqsanswer').load('http://royta.org/module/faqs/get.php',{codedgive:codefaqs},function(applycode){
        $('#faqsanswer').html(applycode);
        $("#faqsmain").removeAttr("disabled");
        $('#imgloadfaqs').hide(500);
    });

Comments

1

Use following code snippet to show and hide.

    $(document).ready(function() {



// Setup the ajax indicator

$('body').append('<div id="ajaxBusy"><p><img src="images/loading.gif"></p></div>');



$('#ajaxBusy').css({

display:"none",

margin:"0px",

paddingLeft:"0px",

paddingRight:"0px",

paddingTop:"0px",

paddingBottom:"0px",

position:"absolute",

right:"3px",

top:"3px",

width:"auto"

});

});



// Ajax activity indicator bound to ajax start/stop document events

$(document).ajaxStart(function(){

$('#ajaxBusy').show();

}).ajaxStop(function(){

$('#ajaxBusy').hide();

});

To read more about the same follow http://skfox.com/2008/04/28/jquery-example-ajax-activity-indicator/

if you use this approach on all ajax request you will get spinning image, so you do not need to code for all request and it will lead to save extra efforts.

For working example follow jsfiddle link http://jsfiddle.net/re57j/

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.