AJAX problem using Safari 3 Beta
Hello everyone. I'm a casual jQuery user and have noticed a bug that
affects only Safari 3 (beta, Mac+PC). In general terms, the bug
happens when a person submits a form via AJAX, the AJAX response
redirects the browser to a new URL, and then the user submits a 2nd
form on the 2nd page.
I've created a test scenario to demonstrate the problem. I'm hoping
this isn't too complex to follow.
http://txtblaster.com/temp/temp
http://txtblaster.com/temp/temp2
When you visit either of those pages and click "Continue" you trigger
the "basic_information_form_actor()" javascript function. This
function uses jQuery's .load() method to load dynamic_forms.php into a
div with some $_GET or $_POST variables (not sure which, not really
relevant to this problem). One of those variables is "handler" which
tells dynamic_forms.php what to do with the rest of the variables.
The key relevant point is that depending on the handler, a different
response can come back. The handler for /temp/temp is
"safari_test_handler", while the handler for /temp/temp2 is
"safari_test_handler_2". Both handlers will identify themselves upon
submitting the forms. The only difference between these handlers is
that the former redirects the browser to /temp/temp2, while the latter
does nothing.
So, here's where we get to the bug. In Safari, go to the first URL and
hit "Continue". You'll see that "safari_test_handler" was run and
you'll get sent to the 2nd URL. Hit "Continue" again and
"safari_test_handler" will get run again. That's not supposed to
happen. Reload the 2nd URL and hit "Continue". The 2nd handler,
"safari_test_handler_2", gets run as it should.
Now try doing the same procedure in Firefox. You should see the
intended functionality.
So what's happening? I assume the following line is not getting reset
when the browser is redirected from the first URL to the 2nd URL:
<input type="hidden" name="handler" id="handler"
value="safari_test_handler">
I'm also assuming Apple is to blame and not jQuery. My hope is that
someone smarter than me can effectively communicate their error to
them. Maybe all that's required is pointing them to this thread. And
of course if the person to blame is me, please let me know so I can
correct my mistake.
Thanks in advance to everyone who reads this. You guys do great work
and I greatly appreciate it.
Brian