Reputation: 1964
I am using the following code to send my username and password to backend. The reason that I am sending them in this way is that I am showing the login form in a lightbox and need to show the result messages "You are authenticated", "Not authorized" in the lightbox without closing it.
<form id="authform" onsubmit="return authenticate()">
...
I am wondering if it is a secure practice to send the username and password through ajax to backend? if it is not what would be a better approach as I need to show the form in a lightbox and need to keep it open to show the results.
Upvotes: 0
Views: 703
Reputation: 463
An AJAX request is just an HTTP request, essentially it's the same as what's happening if you were to write your form to submit the form data through a new page load. The form data is sent as POST data in the HTTP request whether or not the request is performed asynchronously.
As others have suggested, having the request go over SSL will improve security. You should consult your web host on how to purchase and install an SSL certificate.
Upvotes: 1