AJAX/JQUERY update div?
-
How can I update a div using AJAX/JQUERY? I ask this because my div re-loads every 10 seconds, and in the response it has checkboxes. When it reloads, the checked ones disappear, meaning they aren't checked anymore. Now this could be a pain to try to check a lot of them, then have them disappear after 10 seconds. How could I make it so that it compares the response and if it is different only insert the new data, not load the whole thing? Currently I have: <script src="http://code.jquery.com/jquery-lates… <script> $(document).ready(function() { $("#table").load("response.php"); var refreshId = setInterval(function() { $("#table").load('response.php'); }, 9000); $.ajaxSetup({ cache: false }); }); </script>
-
Answer:
Just grab your set of checked boxes before you call the refresh. Then after the refresh, set them to checked again. So inside your setInterval function, you could do something like this... $ch = $('#table').find('input:checked'); $('#table').load('response.php'); $ch.attr('checked', 'checked'); // or for jQuery 1.6+ // $ch.prop('checked', true);
Kyle at Yahoo! Answers Visit the source
Other answers
9000= 9 second <script src="http://code.jquery.com/jquery-lates… <script> $(document).ready(function() { $("#table").load("response.php"); var refreshId = setInterval(function() { $("#table").load('response.php'); }, 0); $.ajaxSetup({ cache: false }); }); </script> now you try
Priyanka
Related Q & A:
- How to create div that can be dragged up to reveal content?Best solution by Stack Overflow
- How to use ajax with autocomplete in jquery?Best solution by Stack Overflow
- How to target the parent div from child div?Best solution by Stack Overflow
- How to execute ajax script on Jquery mobile?Best solution by Stack Overflow
- How to wrap jQuery function in a div?Best solution by Stack Overflow
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.