Jquery load https url

后端 未结 3 661
遇见更好的自我
遇见更好的自我 2021-01-12 09:26

I have this problem. In external web site I have a script like this:

相关标签:
3条回答
  • 2021-01-12 09:42

    I had this issue on Ruby on Rails webpage and the the mistake was to use "_url" helper instead of "_path" helper, on a https webpage:

    in a view: wrong: borrar_linea_factura_url(l)

    ok: borrar_linea_factura_path(l)

    As a recap of said before:

    "_url" helper generates /controller/action/params

    "_path" helper generates https://controller/action/params

    0 讨论(0)
  • 2021-01-12 09:49

    A mixed content error happens when:

    • you try to load secure content SSL(https) on a page served insecurely (http) served

    Or the opposite

    • you try to load insecure content (http) on a page served securely SSL(https) served

    Your error message is warning that your calling page has been loaded in insecure mode

    You haven't explicitly explained this, but your error indicated your page is being served without SSL. When you try to load a protected resource this becomes a mixed mode problem of protected resources and insecure.


    If possible, you try to serve the reference file the same way

    • You can serve your main page in SSL (https)

    • You can request the partial page in http

      $('#idtest').load("http://example.com/index.html")

    or

    • Just as you have resolved it, request the partial page without protocol. Now your loaded file will be loaded using the protocol used by your page.

    About your specific resource:

    I tried loading:

    http://example.com/index.html

    and

    https://example.com/index.html

    The result was the same. I got a simple page with the message:


    Example Domain

    This domain is established to be used for illustrative examples in documents. You may use this domain in examples without prior coordination or asking for permission.

    More information...

    0 讨论(0)
  • 2021-01-12 10:02

    I think it is more a problem of cross origin domain.

    the $.load function of jquery use ajax to load the url and so you cannot do cross domain call if the target URL does not implement CORS headers.

    In your example, the server example.com must return a header

    Access-Control-Allow-Origin: *
    

    You can also replace * with the domain of the page that want to load the content by AJAX.

    A good blog post on how to use CORS: http://www.html5rocks.com/en/tutorials/cors/

    0 讨论(0)
提交回复
热议问题