This function should not be called onsubmit, but rather before the form is submitted.
It is a hack to fix a problem with Safari/Mac...... dating back to 2005!!!! (still not fixed in 2010) That is, multipart form submits fail completely with this combination (hence the reason it should be called *before* a form submit).
Wish old Jobs would spend more time fixing his own bugs before dumping on everybody else.
The easiest way to implement Ajax is to use a library such as jQuery. The sample posted above uses the Prototype library.
If using PHP on your site, the function must make an Ajax call to a file with the following in it:
Code:
<?php header("connection: close"); ?>
Use whatever is appropriate for your programming language.
mm2703 - The code you posted won't work as is. The path for the Ajax request must be set correctly, eg.
Code:
new Ajax.Request("cc.php", { asynchronous:false });
Then you need to create a file named cc.php and place in that the first code snippet I posted. The function you posted requires the Prototype library, so you need to download that and call it into your page. The "new Ajax.Request()" is how Prototype sends an Ajax request.
I would lean toward submitting your form using javascript, because you must execute the closeKeepAlive() function before the form itself is submitted. Alternatively you could try the following on your form page, which again is Prototype dependent code:
Code:
<script type="text/javascript">
document.observe("dom:loaded", function() {
closeKeepAlive();
});
</script>
This will fire the function as soon as your form page has loaded, which should work.
Last edited by Backslider; 11-13-2010 at 02:45 AM..
|