<script type="text/javascript">
var listAction = #{jsAction @list(':search',':size',':page') /}
$('#result').load(listAction({search: 'x',size: '10',page: '1'}),function() { $('#content').css('visibility','visible') }) </script>
$.post(listAction,function(data) { $('#result').html(data); });
The#{jsAction /}tag returns a JavaScript function which constructs a URL based on a server action and free variables.
例子代码
<script type="text/javascript" src="@{'/public/javascripts/jquery-1.4.2.min.js'}"></script>
var listAction = #{jsAction @Application.t(':name')/}
$(function(){
$('#result').load(listAction({name: "jsun's name"}),function(data){
alert(data);
})
});
</script>
<div id="result">result</div>
public class Application extends Controller{
public static void t(String name){
System.out.println("name:"+name);
renderJSON("{name:ok}");
}
}