开发者

Want to know the behavior of html form in firefox?

开发者 https://www.devze.com 2023-04-12 22:59 出处:网络
I have an issue only in firefox: I am generating query string using my own method with form like <form name=\"mytestform\" a开发者_如何学Cction=\"/submit.do\">

I have an issue only in firefox:

I am generating query string using my own method with form like

<form name="mytestform" a开发者_如何学Cction="/submit.do">
   <input name="hiddenID" value="12345" type="hidden" > 
</form>

this page is called via ajax every time the value hiddenID changed every request.

When I am getting form data using getFormData(mytestform) it return the first accessed form value ( i.e all the time I am getting the value hiddenId=12345 ) .

If I used getFormData(document.mytestform) it's working properly.

I am not sure the form objects are cached in firefox or not when i am using ajax .

Please explain me what's the logic behind it ?


The browser has two versions of your page. The orignial what it looks like when it is loaded and the current version after all javascript is executed. If you view the source code of the page you get the original.

I guess the same thing happend here. By using document.mytestform you access the current version of the page.


The default method of sending the form data is GET. This enables the response to be cached. If you do not want that behaviour use the POST method.


The whole response will be cached unless you specify Expires: -1 as a header on the response or change the query string - even with AJAX. A quick solution is to append new Date() as an extra parameter tot eh AJAX request e.g.

$.GET("myURL/myForm.jsp?nocache="+new Date());

There are more elegant solutions, but this should hopefully be enough to prove it is caching that is your issue

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号