Play Framework ajax集成使用

前端之家收集整理的这篇文章主要介绍了Play Framework ajax集成使用前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

<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}");

}

}

猜你在找的Ajax相关文章