Cannot submit HTML form in mobile browser (Nokia/S40 “Response unknown”)

June 19th, 2012 | by Sean |

A quick note, because this stole several hours of my life. I knocked up a little web application with a trivial web form which was CSS, cookie and javascript-free in the expectation that it would work even on elderly mobile phones, so long as they had a browser. It was properly “Web1.0” and worked a treat in my usual selection of browsers. Validator.w3.org said it was valid HTML. The page is a form with one or two (visible inputs) with hidden inputs set by the server-side code to maintain some state across several requests.

I copied the application up to a public host, ran it there and opened it up with my trusty Nokia 6500 Classic. It showed the first page in the series of 4, but then the submit input button – which should have submitted the form by post – didn’t work. The browser popped up an alert saying “Response unknown” (on the Nokia, the other phones I tried just ignored me). There were plenty of pages to read which seemed similar, but none which helped me find the answer. I ended up copy-pasting the dynamically generated page source into a file on my host and repeatedly edited and reloaded it on my phone until I found the problem.

It was my fault: I’m too used to modern browsers ‘helping’ me by guessing what I intended to happen when I wrote my bad page source. I had acquired a religious belief that the form element didn’t need an action attribute and omitting it would cause the form to be submitted to the URL from which it was requested. The old phones I tried (the Nokia and a throwing Samsung) would not submit a form without an action attribute. Their browsers were presumably designed in line with the HTML4 spec, which says that action is a REQUIRED attribute. HTML5 doesn’t say whether the action attribute is required or not, saying instead

The action and formaction content attributes, if specified, must have a value

(and then a couple of lines later, they emphasise the wrong word, “it” instead of “if”, just to test if you’re reading carefully)

The fix was straightforward: I just copied the request-URI into an action attribute for the form element and the pages now work a treat on the two old phones I have here. I hope that’s useful to you if you’re developing apps for yesterday’s User-Agents!

Post a Comment