如何在struts2中使用$ .ajax()方法

Hello All i am using struts 2 and jquery plugin 1.8. Now i searche on google for using $.ajax() methos in struts. but i thoing i am not typing right keywords. Can any one give me tutorial how can we user this function with struts and handle response as String.

jquery is a javascript library and it can be included in struts just like any other framework, in the jsp page add the jquery

 <script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.8.1.min.js" type="text/javascript" ></script>

after that you can use it like

<script type="text/javascript">

$(function(){ //document ready handler to ensure that the jquery is executed after the DOM is loaded

  //your code here
 $.ajax({
   url:'/your/path/',
   type:'POST',//by default is GET
   success:function(data){

    //success handler code
   },
   error:function(jxhr){
    console.log("o0ps!!");
   }

 });
});

</script>
$.ajax({
        type:'POST',
        url:'ajaxAction?nodetitle='+title+'&filename='+fil,
        dataType:'json',
        success:function(data)
        {  
             console.log(stringify(data));                              
        }
 });    

Explanation

1.Type is method type: Get or Post.

2.url is where you want to redirect here ajaxAction it is an action java file where you want to redirect. and after ? nodetitle and filename is two arguments send to action page.

3.dataType is: in which format you want your data back. here in json format.

4.Success Function: if Data Comes Back Successfully. then we use Stringify method to get data or you use System.out.println on server.