problem about out-of-band-Collection of common programming errors
Patrick
jquery ajax asynchronous callback out-of-band
I have a click handler bound to a list of radio buttons.When someone clicks any of these buttons, an ajax request is performed, which goes away to a server, and comes back with some data, which is injected into the page.$(‘ul#tag_picker’).find(‘input’).click(function(e){var type = ($(this).attr(‘type’) == ‘radio’) ? ‘radio’ : ‘checkbox’;if($(‘ul#tag_picker input[type=”radio”]:checked’).length < 1 && type === ‘checkbox’){ e.preventDefault();return false;}var value = $(this).val();var word = $(this).siblings(‘label’).text();tag = {};tag.tag_id = value;tag.tag_word = word;tag.jumper = di.tags.jumpers[0];//tag.privilege = ui.item.privilege;args = {};args[‘jumper’] = di.tags.jumpers[0];args[‘name’] = ‘selected_tags[]’;//args[‘class’] = ‘tag genre_tag’;tag.privilege = ‘genre’;if (type === ‘radio’){args[‘main_tag’] = true;}else if ( $(this).siblings(‘input[type=”radio”]:first’).is(‘:checked’) ){$(this).attr(‘checked’,’checked’);return false; }action = ($(this).is(‘:checked’)) ? ‘add’ : ‘remove’;user_select_tag(tag, action, args); //
Originally posted 2013-11-06 03:13:27.