跨域請求時攜帶cookie

$.ajax({
       type : "POST",
       url : url,
       cache: false,
       async : false,
       data : jsonData,
       dataType : 'json',
       timeout : 10000,
       crossDomain:true, //設置跨域爲true
       xhrFields: {
           withCredentials: true //默認情況下,標準的跨域請求是不會發送cookie的
       },
       success : function(obj) {
           ......
       },
       error : function(data) {
           ......
       }
   });

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章