load function works once only
I've gotten this code to work the first time that the user changes the select option:
- $('select.third, select.fourth').change(function(event){
- var id = $(this).siblings('.hidden').text(),
- token = $('#token').val();
- param = $(this).hasClass('third') ? 'isSold' : 'isActive';
- value = $(this).val();
-
- $('div#allSheepDisplay').contents().remove().end().load(
- 'db-interaction/animals.php',
- {
- action: 'update',
- id: id,
- token: token,
- param: param,
- value: value
- },
- function() {
- $('select.third').filter(function(){return $(this).val() == '1'; }).css({backgroundColor: 'yellow'});
- $('select.fourth').filter(function(){return $(this).val() == '0'; }).css({backgroundColor: 'red'});
- }
- );
- });
Everything works as I expect - the POST request is made correctly, the database is updated, and the display updates correctly. However, if I repeat the same action, selecting a different value, nothing happens until I refresh the page, at which time I can then make the change. Thoughts?