2013-02-09 94 views
0

嗨我想从我的grails控制器发送数据到JavaScript函数。我已经使用escape(),但它没有帮助。以下是Fiddler展示的内容。我想是换行引起的问题..编码数据发送到javascript

控制器:

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'); 
+3

json ..?如果您使用的是php,请尝试json_encode – dmp 2013-02-09 11:05:22

+0

它可以是连字符,例如10 - 15.尝试没有它们。 – uchamp 2013-02-09 13:56:19

+0

你在客户端有什么错误? – 2013-02-09 14:05:39

回答

1

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

相关问题