【发布时间】:2013-12-11 03:30:54
【问题描述】:
我是 ajax 新手。我正在尝试从我的 gsp 页面向控制器操作发送请求。但我失败了。它没有调用控制器操作并且页面正在重新加载。任何人都可以看看这个并提供帮助。下面是我的查看页面>>>
<%@ page contentType="text/html;charset=UTF-8" %>
<html>
<head>
<title>Ajax First Example</title>
<g:javascript plugin="jquery" library="jquery" src="jquery/jquery-1.7.2.js"/>
<script>
function callAjax(){
$.ajax({
url: "returnMe",
type:"post",
dataType: 'json',
// data:{ids:JSON.stringify(idList), option:option, id:id}
success: function() {
alert(1)
}
});
}
</script>
</head>
<body>
<form name='myForm'>
<input type="submit" value="Call Ajax Function" onclick="callAjax()">
</form>
</body>
</html>
这是我的控制器操作 >>>
def returnMe = {
String msg = 'sdfsdf'
render msg as JSON
}
【问题讨论】: