posting AJAX call to http url from both HTTP and H

2019-08-12 07:32发布

问题:

I have to integrate a 3rd party newsletter signup form that makes an AJAX call to HTTP url.

That form I'm placing on pages that use HTTP or HTTPS protocols ( http for home pg., ect.; https for ecommerce related stuff )

I don't think anything is sent back from the destination server ( at least I can't see the response) other than status code.

I'm getting 200 OK whether I submit the form from HTTP or HTTPS page and watch what's going on with it in Firebug. Wonder if it's safe to assume the call gets processed successfully?

Usually, I like to have a proof positive that something worked or didn't, but in this case all test signups show up the next day, ( due to sign up getting processed as some scheduled task I'm guessing ), hence the unease.

回答1:

You can use window.location.protocol to check whether you're currently on a Secure connection, and if so, you should AJAX a secure url.



回答2:

You can call https server from http but can't call http from https directly using AJAX.

To call http user from https server you need to call your server side application from java script using AJAX, and then call http url from your server side application then send back this to the client.



标签: ajax http https