Cross-domain issues Ajax_ajax request --- browsers do not allow cross-domain ajax get server data, then we will use to achieve cross-domain jsonp

1, the cross-domain knowledge --- cross-domain data acquisition is an objective reality

  Under the actual development of cross-domain access to services but also the demand side data is also very common, because resources (even in the same project, different sub-modules) may also be deployed (server, different devices have different domain name or IP on different devices address).

  

  For example: domain name as a domain name of the file you want to access files in the b --- occurs at this time cross-domain request via ajax request, the browser does not allow cross-domain ajax data acquisition server

    

    

    

    

 2, cross-domain solutions

  

  a, jsonp (jquery provided in the jsonp to solve cross-domain problems) --- mainstream solutions (development interface is relatively simple, there is no compatibility issues)

     

   b, jsonp principle --- jsonp fatal problem: Only get requests (so the last general background to solve the problem through technology cross-domain requests)

    

    

    

    

    Static is not common understanding on the line, usually with dynamically created in the form of labels

    

    

    

    -------------------------------------------------------------------------------------------------------------------

    

    

    Jsonp nature is not Ajax, but. . .

    

  c, jquery good package jsonp cross-domain data acquired

    

    

    

 

    

    

    

    If the back-end is not called callback, and that the front end can customize the name, jquery which is written very flexible (front-end to meet the back-end)

    

       

   c, jsonp scenarios

    

    Typical jsonp interfaces: Interface Standard 3rd party

     

    Good jsonp tone third-party interfaces (jsonp Interface) check data package jquery

    

    

    Interface: the background data is returned instead of a full page, then the url can be said as an interface, the interface type as the data type returned back to sub-type, such as the interface json format interface jsonp

    The site of the following interfaces are generally json interface, data is to use the language background, foreground want to get this json format data is generally looking at the background to the package, and then returned to the front desk to use.

   

     

 

 

     

 

 

    

   

   

   

  

Guess you like

Origin www.cnblogs.com/yangyutian/p/10961754.html