Question

I have a login form. I want to know if using AJAX for login purpose or sending the complete form will be better, both in terms of security and performance?

I intend to make AJAX call as it prevents the page reload when the inputs provided are invalid instead of loading a complete page. What to use?

Was it helpful?

Solution

Nothing wrong with an AJAX-Post (keeping the url-cache clean of user-submitted data), just as long as you have a fallback (for users with javascript disabled). Especially since it is a logon-system.
On the other hand.. if your web-service (the thing/content you are 'selling') fully depends on javascript (like a browser game), then you can forget about that common-sense requirement.

As to performance: yes, it usually is faster since you only communicate a couple of bytes with the (backend-)server.

Edit: optionally you could try to obfuscate/hash the data (username/password) you are sending (since all code required to do that would be in the javascript, there will however never be any real security to that, use SSL to add an extra layer of security).

Hope this helps

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top