Percent-Encode HTML Form Values so That Spaces Become ‘%20’ Instead of ‘+’

I had this great idea, using URL Schemes on macOS apps, assembled by very simple HTML files that contain a <form> only and produce a GET request so that the data is part of the URL: To my dismay, I discovered that all browsers encode spaces in input and textarea elements as plusses: +. Turns out that’s valid and expected.

Continue reading …

Rails.js XHR form callbacks fixed for invalid submissions

I struggled with Ajax form calls in Ruby on Rails for some time now. Because I seem to be anal retentive, I insist the server should respond with HTTP status code “400 Bad Request” or “424 Unprocessable Entity” when form submission turns out to be full with invalid data. Responding with “200 OK” doesn’t make any sense when there was an error on the client side, like an empty or otherwise invalid form. That’s what HTTP codes are for: to comminicate how it went and what happened. Also, we web developers are creating publicly visible Web Services and APIs here, so they should conform to the most basic standards of the transfer protocol we’re using, am I right?

Continue reading …