在Struts2中如何使用$阿贾克斯()方法 [英] How use $.ajax() method in struts2

查看:121
本文介绍了在Struts2中如何使用$阿贾克斯()方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好所有我使用Struts 2的和jQuery插件1.8。现在,我搜索器对谷歌使用 $。阿贾克斯() methos的支柱。但我thoing我不打字正确的关键字。任何一个可以给我教程怎么能用户此功能支柱和处理响应为String。

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是一个JavaScript库,它可以被包含在Struts中,就像任何其他的框架,在JSP页面中添加了jQuery

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>

这篇关于在Struts2中如何使用$阿贾克斯()方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆