如何使用jQuery在Grails页面中发出Ajax请求?
如何在Grails Controller上设置访问方法的URL?让我们说控制器:’机场’,动作:’getJson’并且动作的输入是’iata’.
我能够将静态URL设置为http:// localhost:8080 / trip / airport / getJson,但无法弄清楚如何专门为iata传递输入.
我是Grails的新手,并且遵循IBM的“掌握Grails”教程系列.建议我一些关于在Grails中使用jQuery的好教程.
解决方法
在jquery中使用$.ajax方法
- $.ajax({
- url:"${g.createLink(controller:'airport',action:'getJson')}",dataType: 'json',data: {
- iata: '.............',},success: function(data) {
- alert(data)
- },error: function(request,status,error) {
- alert(error)
- },complete: function() {
- }
- });