SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Wizard bbolte's Avatar
    Join Date
    Nov 2001
    Location
    The Central Plains
    Posts
    3,301
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question IE9 and Chrome not showing loading div during AJAX call

    I'm trying to debug a bit of code and can't seem to figure out why this won't work. I've read through the AJAX/AJAX events on the Jquery site, read through several Stack threads and still this won't work. The script is showing and hiding DIVs during an AJAX call. The DIV with the "loading" animated gif won't show, so it appears to the user that nothing is going on. I was able to get the div to show with a settimeout, but the animation wasn't running. below is the code, anyone have any pointers for me?

    Code:
    function ajax_email_proc() {
        $("div#email_proc_form").hide();          // hide form
        $("div#emaiL_proc_saving").show();     // show loading gif
        $('.procselector:checked').each(function(index) {
            for (var i=0; i< email_array.length; i++) {
            $.ajax({
                 url:'/viewproc/email_view_proc/'+$(this).val()+'/XXXXXXXXXXXX,
    	     type:'POST',
    	cache:false,
    		data:'XXXXXXXXXXXXXXXXXXX',
    		success:function(returnData){
    			$("div#emaiL_proc_saving").hide();
    			$("div#email_proc_done").show();
    	},async:false
    	});//close ajax function
    } // for email array loop
    }); // each loop
    }

  2. #2
    SitePoint Wizard bbolte's Avatar
    Join Date
    Nov 2001
    Location
    The Central Plains
    Posts
    3,301
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    forgot to mention that the form doesn't hide until the AJAX call is complete

  3. #3
    ♪♪ ♪ ♪ ♪ ♪♪ ♪ ♪♪ Markdidj's Avatar
    Join Date
    Sep 2002
    Location
    Bournemouth, South UK
    Posts
    1,551
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    How about going the css way?
    this is what I use to show an action is being executed......
    Code:
    #main.loading div *{opacity:0.7;}
    And then I add "loading" to the className of main before the request goes to the server, and remove it when the request is complete.

    You can have whatever you want in the css
    LiveScript: Putting the "Live" Back into JavaScript
    if live output_as_javascript else output_as_html end if

  4. #4
    SitePoint Wizard bbolte's Avatar
    Join Date
    Nov 2001
    Location
    The Central Plains
    Posts
    3,301
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    it might work, but, after researching more, I think it has more to do with IE and synchronous AJAX calls. If I wrap the AJAX call in a timeout, I get the spinner briefly and then the browser "freezes" until the call is done. Evidently, this is a "feature" of IE (and apparently Chrome as well).

    And, unfortunately, I have to do the AJAX synchronously...

  5. #5
    SitePoint Wizard bbolte's Avatar
    Join Date
    Nov 2001
    Location
    The Central Plains
    Posts
    3,301
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    this is more-or-less working, but as I said, the spinner quits once the AJAX call goes. But then, even the menus are inaccessible in IE until the call finishes.
    Code:
    setTimeout(function() {
    											// Get All Procedures that were selected
    											$('.procselector:checked').each(function(index) {			// Loop through each checkbox
    												for (var i=0; i< email_array.length; i++) {					// And send each one to all email addresses
    
    													$.ajax({
    														url:'/viewproc/email_view_proc/'+$(this).val()+'/XXXXXXXXXXXXXX,
    														type:'POST',
    														cache:false,
    														async:false,
    														data:'XXXXXXXXXXXXXXXXXXXXXXX',
    														beforeSend : function() {
    															$("div#email_proc_form").hide();
    								               $("div#emaiL_proc_saving").show();
    								            }
    														}).done(function(){
    															$("div#emaiL_proc_saving").hide();
    															$("div#email_proc_done").show();
    														});//close ajax function
    												} // for email array loop
    											}); // each loop
    },1000);

  6. #6
    ♪♪ ♪ ♪ ♪ ♪♪ ♪ ♪♪ Markdidj's Avatar
    Join Date
    Sep 2002
    Location
    Bournemouth, South UK
    Posts
    1,551
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    I don't get page freeze in any browser, and my whole site works both syncronously and asyncronously. But then I don't use AJAX or Jquery. My stuff predates that by a little while.
    LiveScript: Putting the "Live" Back into JavaScript
    if live output_as_javascript else output_as_html end if

  7. #7
    SitePoint Wizard bbolte's Avatar
    Join Date
    Nov 2001
    Location
    The Central Plains
    Posts
    3,301
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I do appreciate the input


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •