Hi I’m trying to send data to a javascript function from my grails controller. I already use escape() but it doesn’t help. The following is what Fiddler shows. I suppose is the line break that cause the issue..
controller:
render(text:content, contentType: "text/javascript")
data:
addPestMarker( 6, escape('White Fly'), escape('Bemisia tabaci ') , escape( 'N/A'), escape(' N/A'), escape('N/A'), escape('Install sticky fly traps.'), escape('Nymph measures to 0.3-0.8mm long. Size is about 1mm long with wings. They possess arrhenotoky where unfertilized eggs produce male flies while fertilized eggs produce female flies. Each female can produce 200 eggs in her life time. For whiteflies, development period takes 30 to 40 days depending on temperature.'), '35.0', '70.0','null', 'null');
I believe what you need is
return content as JSON. Grails will serializecontentto JSON and use a proper contet type.