Previously, jquery's Ajax request was used to access rest, and "Get/Post" was used to send HTTP requests. The server always received the "option" method. I learned on the Internet that cross-origin is actually the cause. The result is that neither HTTP header nor Params can be obtained.
Then, I checked the cross-origin call of jquery and found that jsonp can be used,CodeAs follows:
VaR Postdata = {
' Authorization ' :
' AWS cuimeng1: 1232432453 ' }
VaR Ddate =
" Wed, 01 Mar 2009 12:00:00 GMT " ;
$. Ajax ({
URL: host_url,
Type:
' Get ' ,
Datatype: ' Jsonp ' ,
Jsonp: ' Callback ' ,
Data: postdata,
Header :{
" Authorization " :
" AWS cuimeng1: 1232432453 "
},
Beforesend: function (xhr ){
Xhr. setRequestHeader (
" Date " , Ddate );
Xhr. setRequestHeader (
" Authorization " ,
" AWS cuimeng1: 1232432453 " );
},
Success: function (result ){
Alert (
' OK ' );
},
Error: function (xhr, textstatus, errowthrown ){
Alert (xhr. status );
Alert (textstatus );
}
});