ajax same-origin policy, jsonP cross-domain access

Browser For safety reasons, requiring ajax request, must meet the same origin policy

Provides: access protocol: // domain: port number are the same-origin policy meet, the browser can parse the data correctly, or if there is a requirement is not met, the part of cross-domain access, the browser can acquire data is normal, but not parse the returned value

ajax: can not cross-domain access; you can cross-domain access by httpClient

Cross-domain principle

javaScript of src can achieve cross-domain

Defined callback function

The return value package specially formatted

<Script type = "text / JavaScript">
         / * the JS is interpreted language execution   * / 
        / * define the callback function   * / 
        function Hello (Data) { 
            Alert (data.name); 
        }
     </ Script> 
    ! <- this json been saved to the browser waits for the call, but did not call the name of the function -> 
    <Script of the type = "text / JavaScript" src = "http://manage.jt.com/test.json"> </ Script>

json special

hello({"id":"1","name":"tom"})

 

format

Guess you like

Origin www.cnblogs.com/Web-spring/p/12053654.html