0

您好我正在尝试从我的 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');
4

1 回答 1

1

我相信你需要的是return content as JSON. Grails 将序列化为contentJSON 并使用适当的 contet 类型。

于 2013-02-09T22:55:18.993 回答