javascript - onComplete for Ajax.Request buggy with cached content -


I have an Ajax. The request is in which I show and hide a load animation gif to load and use. The problem is that every 10 clicks fails to hide the load animation, and it just keeps animating there although the AJAX request has returned successfully. I have several element elements, each with its own related load animation and an onclick with Ajax. This request looks like:

  & lt; Div id = "word_block_ <% = word_obj word% & gt;" class = "word_block" & gt; & Lt;% = image_tag ("ajax-loader_word_block.gif" ,: id = & gt; "load_action_only # {word_obj.word}" ,: style = & gt; 'display: none')% & gt; & Lt; A href = "#" onclick = "request ('/ test / ajax_load', {asynchronous: true, empty: true, onloading: function) (element. Show ('load_animation_ & lt;% = word_obj.word % & Gt; ')}, interactive: function () {Element.hide (' load_animation_ ;)}}}); return; "& gt; Click here & lt; / A & gt; & Lt; / Div & gt;  

Does it seem like something wrong with it? Maybe I should try to delete the inline onclick and add an onclick to a program with javascript? I do not really know why this is happening, I'm using the prototype library with Ruby on Rail.

I found that the onloading property should also fail. .. Assume that your query has already been cached and almost straight back comes back to your front end code. Now let us also say that for some reason, executing the onloading method takes more time than the whole method. Finally, we become crazy and believe that Ajax is asynchronous and it will not wait for the method of loading before it completes. And then you have a reason for your problem! To: - The request is sent - The onloading method is removed, but for some reason not yet started - the request comes back almost immediately - the complete method is removed and starts directly => You end with an end-to-end method Ending before the onloading starts: Your element will hide and then show up!

As a work, why not make your "Element. Show" ('load_animation_ & lt;% = word_obj.word%>' '}} "right before creating your Ajax Request object? Do not trust the onloading method and "asynchronous" which runs with it?

Additionally, I always add a request request: ["If-Modified-To", "Friday, 31 December 1999 23 : 59: 59 GMT "]" To cache my Ajax request, especially to stop in IE, where cached Ajax Requests can get big time!


Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -