Improved JS logic to update field groups via AJAX

Signed-off-by: Elliot Condon <e@elliotcondon.com>