I WCF-Dienste unter Verwendung von AJAX, unten zu nennen versuchen mein Code:Wie kann ich diesen Fehler beheben
$.ajax({
url: "http://localhost/TestingServices/Service1.svc/GetData"
data: "{'value:1}",
type: "POST",
dataType: "json",
contentType: "application/json; charset=utf-8",
success: function(data) {
alert(data);
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
alert(textStatus);
}
});
Aber nach Ausführung gibt es mir folgende Fehlermeldung:
XMLHttpRequest cannot load
http://localhost/TestingServices/Service1.svc/GetData.Response to
preflight request doesn't pass access control check:
No 'Access-Control-Allow-Origin' header is present on
the requested resource. Origin 'null' is therefore not
allowed access. The response had HTTP status code 404.
Can jemand mir helfen, wie das zu lösen?
entfernen content: „application/json; charset = utf-8 "und dann versuchen ,,, –
bitte http://stackoverflow.com/questions/33820142/getting-request-doesnt-pass-access-control-check-no-access-control-allow-orig – RRR
Nun, ich bekomme dis-Fehler: POST http: //localhost/Wcf/service1.svc/GetData 415 (Die Nachricht kann nicht verarbeitet werden, da conten t type 'application/x-www-form-urlencoded; charset = UTF-8 'war nicht der erwartete Typ' text/xml; charset = utf-8 '.) – tiya