MDL-42072 badges: Fix output and headers in badges ajax scripts