HTTP Techniques: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 8: | Line 8: | ||
* Another solution would be (untested) to generate a unique key in an Ajax call, thus forcing the browser to actually make the call. | * Another solution would be (untested) to generate a unique key in an Ajax call, thus forcing the browser to actually make the call. | ||
== Ajax File Upload == | |||
* The idea here is to use a hidden iframe that the upload form will target. To get back JS control once the upload is finished, several techniques are possible. The following one registers a "load" event listener on the upload frame: | |||
$("uploadFrame").observe("load", this.myCallBack.bindAsEventListener(this)); | |||
* To access content inside an iframe, the following JS code can be used: | |||
data = frames["uploadFrame"].document.getElementById("uploadFrameResultData").innerHTML.evalJSON(); |
Revision as of 10:09, 16 February 2008
Cache-control
- Under Firefox, when you press the back button, Firefox does not refetch the page from the server and it does not even retrieve it from cache. It retrieves it from RAM. This can cause problems when you want to refresh the pages (typically, if some information has been added to the HTTP session for example).
- Even if the JavaScript code makes an AJAX call this call too will be cached.
- The solution is to use (in the HTTP headers) the Cache-Control directive with argument: no-store. Not that no-cache will *not* be enough!
- Another solution would be (untested) to generate a unique key in an Ajax call, thus forcing the browser to actually make the call.
Ajax File Upload
- The idea here is to use a hidden iframe that the upload form will target. To get back JS control once the upload is finished, several techniques are possible. The following one registers a "load" event listener on the upload frame:
$("uploadFrame").observe("load", this.myCallBack.bindAsEventListener(this));
- To access content inside an iframe, the following JS code can be used:
data = frames["uploadFrame"].document.getElementById("uploadFrameResultData").innerHTML.evalJSON();