2014-01-16 47 views
0

我使用下面做一個CORS請求:缺少Authorizaton頭和jQuery

// This causes a problem.... 
     $.support.cors = true; 
     $.ajax({ 
      url: url, 
      type: 'GET', 
      data: {}, 
      dataType: 'json', 
      contentType: "application/json; charset=utf-8", 
      crossDomain: true, 
      success: function (result, textStatus, jqXHR) { 
       alert('Success'); 
      }, 
      error: function (jqXHR, textStatus, err) { 
       var problem = jqXHR.responseText; 
       if (problem == undefined) { 
        problem = err; 
       } 
       if (window.console) console.log("Error with ajax call: " + problem); 
      }, 
      beforeSend: function (xhr) { 
       var headerValue = "Basic <base64 user name and password>"; 
       xhr.setRequestHeader('Authorization', headerValue); 
      } 
     }); 

和提琴手要求是:

GET http://api.scenictours.com/api/Guests?query=firstName::|surname::Testcustomer|dateOfBirth::|gender::|postcode::|email::|phone::|clientmarket::AU HTTP/1.1 
Accept: */* 
Origin: http://localhost:50485 
Accept-Language: en-AU,en-US;q=0.7,en;q=0.3 
Accept-Encoding: gzip, deflate 
User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; Trident/7.0; rv:11.0) like Gecko 
Host: api.scenictours.com 
DNT: 1 
Connection: Keep-Alive 
Pragma: no-cache 

誰能告訴我,爲什麼認證頭沒有了嗎?

回答