Grails中的jQuery Ajax请求 [英] jQuery Ajax request in Grails
问题描述
如何使用jQuery做Ajax请求Grails中的网页?
How to use jQuery to make Ajax request in Grails pages?
如何设置击中Grails的控制器的方法的网址是什么?比方说,控制器:机场,行动:。的getJSON,并输入到行动国际航协
How to setup a URL hitting a method on Grails Controller? Let's say controller:'airport', action:'getJson' and input to the action is 'iata'.
我能设置静态的URL为的http://本地主机:8080 /跳闸/机场/的getJSON
,但无法弄清楚如何通过输入IATA专
I am able to set static url as http://localhost:8080/trip/airport/getJson
but not able to figure out how to pass input for iata specifically.
我是相当新的Grails和IBM之后的'掌握Grails的系列教程。不要认为我在使用jQuery与Grails的一些很好的教程。
I am fairly new to Grails and following IBM's 'Mastering the Grails' tutorial series. Do suggest me some good tutorial on using jQuery with Grails.
推荐答案
在jQuery中使用$就法
use the $.ajax method in jquery
$.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() {
}
});
这篇关于Grails中的jQuery Ajax请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!