您好我正在尝试从我的Grails控制器向javascript函数发送数据。我已经使用了escape()但它没有帮助。以下是Fiddler所展示的内容。我想是导致问题的换行符。
控制器:
render(text:content, contentType: "text/javascript")
数据:
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');
答案 0 :(得分:1)
我相信你需要的是return content as JSON
。 Grails会将content
序列化为JSON并使用适当的上下文类型。