2016-08-30 2 views
-1

Ich versuche, ein Web mit PlanGrid-API zu entwickeln, und ich bekomme Cross-Domain-Anfrage Block Fehler.Fehler: Cross-Ursprungsanforderung Block

var apiKey="API KEY"; 
var password="PASSWORD"; 
$.ajax({ 
    url: "https://io.plangrid.com/projects", 
    xhrFields: { 
     withCredentials: true 
    }, 
    headers: { 
     "Authorization": "Basic " + btoa(apiKey + ":" + password), 
     Accept:'application/vnd.plangrid+json; version=1' 
    }, 
    type: 'GET', 
    crossDomain: true, 
    success: function (data) { 
     console.log(JSON.stringify(data)); 
    }, 
    error: function(data){ 
     console.log(JSON.stringify(data)); 
    } 
}); 

Nach Ajax-Anforderung, ich bin immer Fehler:

„Reaktion auf Preflight-Anfrage nicht Zugriffskontrolle Prüfung bestehen: auf die angeforderte Ressource Nein" Access-Control-Allow-Origin-Header vorhanden ist . 'http://localhost:3000' ist daher kein Zugriff erlaubt. Die Antwort hatte den HTTP-Statuscode 401. "

Kann mir jemand sagen, wo ich falsch liege? Danke

+0

Überprüfen Sie diese http://stackoverflow.com/questions/8163703/cross-domain-ajax-doesnt-send-x-requested-with-header –

+0

nach dem Ausführen der folgenden Änderungen wie in diesem Beitrag gesagt, es hat nicht funktioniert. wieder der gleiche Fehler. danke thoughh –

+0

Sie sind berechtigt, auf diese URL zuzugreifen? –

Antwort

0

Versuchen Sie, https zu http in AJAX zu ändern und zu sehen, ob es funktioniert. Passen Sie das Protokoll wie Ihre Domäne an, die localhost ist. Ihr localhost ist unter http.

+0

es funktioniert nicht, nachdem es http auch gemacht –