Grails中的jQuery Ajax请求

前端之家收集整理的这篇文章主要介绍了Grails中的jQuery Ajax请求前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
如何使用jQuery在Grails页面中发出Ajax请求?

如何在Grails Controller上设置访问方法的URL?让我们说控制器:’机场’,动作:’getJson’并且动作的输入是’iata’.

我能够将静态URL设置为http:// localhost:8080 / trip / airport / getJson,但无法弄清楚如何专门为iata传递输入.

我是Grails的新手,并且遵循IBM的“掌握Grails”教程系列.建议我一些关于在Grails中使用jQuery的好教程.

解决方法

在jquery中使用$.ajax方法
  1. $.ajax({
  2. url:"${g.createLink(controller:'airport',action:'getJson')}",dataType: 'json',data: {
  3. iata: '.............',},success: function(data) {
  4. alert(data)
  5. },error: function(request,status,error) {
  6. alert(error)
  7. },complete: function() {
  8. }
  9. });

猜你在找的jQuery相关文章