Cross-domain requests and solutions

What is cross-domain and cross-domain request scheme

A domain is such a concept: We believe that if the protocol + domain + port number are the same, then that is the same domain.

For safety reasons, in order to avoid CSRF attack, the browser will intercept the Ajax request non-homologous.

Solution:

  1 jsonp

    Advantages: limited by the same origin policy; it's better compatibility, can run more ancient browser.

    Cons: only supports GET requests without the support of other types of HTTP POST requests, request

  2 hearts

    Pros: Supports all types of HTTP requests; can be initiated using normal XMLHttpRequest request and obtain data than JSONP have better error handling.

    Cons: Although most modern browsers already support CORS, CORS compatibility but not as JSONP, some older browsers only support JSONP

Guess you like

Origin www.cnblogs.com/katu/p/11505742.html