I am sure that another issue related to non-sleep. I send him as a sacrifice to Elder God Murphy: as soon as I reveal my misunderstanding so that everyone can see, I will surely find the answer itself, which otherwise would elude me within a few hours (in the form of further repentance, Then I will publish the answer) .
I have an HTML form that displays as
<form method="post" id="mysearch" action="/search/?uid=1701"> <input id="searchterm" type="text" name="query" /> </form>
The form can be submitted via jQuery $.POST with the URL '/ search' and the data { uid: '1701', query: $('#searchterm').val() } , and it works.
If I press ENTER after typing something and thus override the jQuery view, the following will happen:
Answer 301 looks like Laravel4, added explicitly:
HTTP/1.0 301 Moved Permanently Date: Thu, 28 Nov 2013 14:05:29 GMT Server: Apache X-Powered-By: PHP/5.4.20 Cache-Control: no-cache Location: http://development/search?uid=1701 Connection: close Content-Type: text/html <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="refresh" content="1;url=http://development/search?uid=1701" /> <title>Redirecting to http://development/search?uid=1701</title> </head> <body> Redirecting to <a href="Redirecting to http://development/search?uid=1701">Redirecting to http://development/search?uid=1701</a> </body> </html>
This is not the same as this question , because a redirect is expected, and this is an answer to the unwanted. Here he redirects himself, which is generated without a reason that I can (for now) see.
I suspect that for some reason I am running a "security redirect" described in this other answer that jQuery does not start (either because it puts everything in POST, while here I have one parameter in the URL address and the other in POST, or because jQuery uses XHR).
I thought it might be CSRF protection, but this particular route is not protected. As a last resort, I CSRF-protect the route and add the token to the form, even if it looks a bit like voodoo. Something vaguely similar happens in Rails .
Bypass
I have not one, not two, but three workarounds that neatly circumvented the question of why this is happening:
- (the most violent) blocks the
keyUp event on the form. - redirect form submit event in jQuery
- (most transparent) redirects the specified event to
$('#search-button').click()
... but I would like to do without a button at all (what I could do with jQuery) and without jQuery in general . And also to understand what is happening here. I'm 99% sure I'm missing something obvious.
Debugging
Now I will grep -r "Redirecting to" * entire source code of the framework (I expect to find something in Symfony/Components/HttpFoundation/ResponseRedirect ) and take it step by step from there.