ajax historyback,Struts2: jQuery, AJAX and history back button

在使用Java Struts2和jQuery的web应用中,作者遇到一个问题:在Firefox浏览器中,从success.jsp通过历史回退按钮返回welcome.jsp时,加载了ajax内容的字段无法保留数据,而在Internet Explorer中却正常。问题集中在ajax加载的字段之后的数据丢失。文章探讨了这个问题并询问是否使用jquery.address插件能解决此问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

I have a Java Struts2 web application which uses jQuery and ajax.

Source code for the JSPs is given below.

In welcome.jsp, there are three text-fields, one select and one field

which is loaded using ajax($.load()).

Clicking on submit button after entering data in welcome.jsp fetches success.jsp.

If we click on back button(mapped to history.back()) from success.jsp, we are back to welcome.jsp

but data in fields are not loaded properly.

All fields before the field which is loaded using ajax retain data in them,

but fields after the field which is loaded using ajax do not retain the data.

The above problem occurs in the Firefox browser, but not in Internet Explorer.

Will the jquery address plugin resolve this issue? if so, how do i go about it?

The documentation at their site didnot help me much as i am new to jQuery.

I reffered below urls.

welcome.jsp

.......................................

.................................................

Welcome

$(document).ready(function(){

$('#categorySelect').change(function(){

var catValue = $(this).val();

$('#subcategorydiv').load("suburb.action#resultdiv",{category:catValue});

});

$('#subcategorydiv').load(

"suburb.action#resultdiv",

{category:"Fruits"});

});

suburbauto.jsp(loaded into subcategorydiv by suburb action)

....................................................

......................

Welcome

success.jsp

.......................

Success

Subcategory:

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值