You could use single quotes for the attribute, i.e. onload='...'
- right now your data string contains double quotes which break everything as they terminate the attribute.
However, it would be much better to keep using double quotes and HTML-escape any special characters ("
, &
, <
and >
) in objNames
! That way you don't get any problems if the data contains single quotes somewhere.