简体   繁体   English

单击每个选项卡时使用struts 1,js,ajax显示不同的数据

[英]Display different data on click of each tab using struts 1,js, ajax

introduction : I am developing Newsetter in struts1, tiles .For front-end i use js and ajax. 简介:我正在使用struts1,tiles开发Newsetter。对于前端,我使用js和ajax。 I have 8 tabs on the top of page. 我在页面顶部有8个标签。 I want to show different data on click of each tab. 我想在单击每个选项卡时显示不同的数据。 As tab (Button) is clicked, a JS function is called which use AJAX call to call action class which set properties of form (respective to that action.) and then I forward to my left.jsp (left.jsp is one file in my layout, used in tiles ). 单击选项卡(按钮)时,将调用一个JS函数,该函数使用AJAX调用来调用操作类,该类设置表单的属性(与该操作有关。),然后转发到我的left.jsp(left.jsp是其中的一个文件)我的布局,用于)。 My left.jsp looks like: 我的left.jsp看起来像:

<div id="left1">
  <form name="Project" method="post" >
    <bean:write name="Project" property="name" />
  </form>
  <form name="KnowAMSS" method="post" >
    <bean:write name="KnowAMSS" property="namexyz" />
  </form>
</div>

** Project and KnowAMSS are two tabs among 8 tabs. ** Project和KnowAMSS是8个标签中的两个标签。

Problem : When I click on another tab same process goes on and displays data to respective tab.. But it also displays the data of previously clicked tab. 问题:当我单击另一个选项卡时,将继续执行相同的过程并向相应的选项卡显示数据。但是,它还会显示先前单击的选项卡的数据。 I don't want those .I want data for only that tab which I have pressed recently . 我不需要这些。我只需要我最近按下的那个标签的数据。 Please help me out in this . 请帮助我。 Thanks . 谢谢 。

There are different way to accomplish your task... 有不同的方法可以完成您的任务...

I recommend you to use an external library like jquery-ui 我建议您使用外部库,例如jquery-ui

Here the example: 这里的例子:

http://jqueryui.com/demos/tabs/default.html http://jqueryui.com/demos/tabs/default.html

The source code is very simple just: 源代码非常简单:

Javascript: Javascript:

$(function() {
    $( "#tabs" ).tabs();
});

HTML: HTML:

  <div id='tabs'>
      // your HTML code
  </div>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM