简体   繁体   中英

How to submit HTTPS forms to a HTTPS server

I need to send a post to another domain featuring HTTPS. If I send it through normal HTTP, the following browser warning message appears, which will scary users:

“Although this page is encrypted, the information you have entered is to be sent over an unencrypted connection and could easily be read by a third party. Are you sure you want to continue sending this information?”

How can I solve this?

I can't change all site to HTTPS, is it possible to submit only the POST form using HTTPS?

Can I do it through Javascript/Jquery? (if yes, is there an example?)

Thank you

The warning is just saying that submitting information from a non-HTTPS site to a site with HTTPS, or vice versa, exposes that information to potential attackers.

If the page your form is on is using HTTP, change it to HTTPS. If the page your form is on is using HTTPS and the URL it's submitting to is HTTP then you will have to change the page it is submitting to to HTTPS. If the receiving site doesn't support HTTPS then there's no way to avoid this warning, unless you submit it from a non-HTTPS page. If the information is sensitive, that is not a good idea.

To change the remote site to use HTTPS, just change the protocol in the URL of your AJAX request.

Maybe this code will do the trick:

$("form").each(function (index, form) {
    form.action = form.action.replace("http://", "https://");
});

But it is possible that the warning won't go away. You could use a text editor and search/replace all action="http:// found in your files to action="https:// .

Hope it helps. Good luck.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM