How use $.ajax() method in struts2

前端 未结 2 1869
天涯浪人
天涯浪人 2021-01-26 05:08

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 a

2条回答
  •  滥情空心
    2021-01-26 05:53

    $.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.

提交回复
热议问题