jquery ajax post to non-ssl page while current pag

2019-07-27 04:24发布

问题:

Ok, situation:

  • an https / ssl page
  • jquery
  • a form
  • submitted via ajax to a non-ssl pagge

getting no usefull response

the same scenario, non-ssl to non-ssl works perfect.

I can view my console, but cant get any usefull info from it why the request fails...

$.ajax({

type: "POST",
url: form.attr("action"),
data: form.serialize(),

error:          function(res){ console.log(res) },
notmodified:    function(res){ console.log(res) },
parsererror:    function(res){ console.log(res) },
timeout:        function(res){ console.log(res) },
success:        function(res){ alert('succes!'); }

});

回答1:

You can't make AJAX calls from non-SSL page to a SSL URL. This violates the SOP (Same Origin Policy) because the protocols (HTTP vs HTTPS) are different. Some old browsers don't have this restrictions but all new ones enforce this now.

Read this article for more details,

http://code.google.com/p/google-web-toolkit-doc-1-5/wiki/FAQ_SOP