CRM-15713 - Case ajax fixes

Resubmit #4719 with an additional patch.