Ich rufe (Ajax Request) einen WCF REST Service an und die Anfrage ist eine Cross Domain Anfrage.Übergreifende Domain jQuery Ajax Anfrage & WCF REST Service
Wenn ich meinen Dienst in der gleichen Domäne bereitstellen, funktioniert alles wie Sahne. Schließlich wird der Dienst in der Produktion in einer anderen Domäne sein.
Ich benutze jQuery 1.5.2. Mein Dienst gibt mir einen Fehler Spruch:
errorThrown: "jQuery15208493315000087023_1334089616458 was not called"
textStatus: "parsererror"
Obwohl in Firefox ich den JSON-Wert sehen kann, aber die Ausführung fällt auf die Fehlerbehandlung von Ajax-Anfrage.
Meine Ajax-Anfrage ist:
function CallService() {
$.ajax({
type: "GET",
url: "http://SomeService/EmpService.svc/GetValues?dv=1455",
contentType: "application/json; charset=utf-8",
dataType: "jsonp",
processdata: false,
success: function (data) {
ServiceSucceeded(data);
},
error: function (jqXHR, textStatus, errorThrown) {
debugger;
alert("Service Error");
ServiceFailed(jqXHR, textStatus, errorThrown);
}
});
}
auf WCF-Dienst Seite, ich habe konfiguriert CrossDomainScriptAccess auf true:
<webHttpBinding>
<binding name="webHttpBindingWithJsonP"
crossDomainScriptAccessEnabled="true" />
</webHttpBinding>
JSON-Antwort, die ich von dem Server erhalten wird:
[{"Message": "Stop On Duty", "MessageTime": "\/Date(1334068773893-0500)\/"},
{"Message": "Start On Duty", "MessageTime": "\/Date(1334068763540-0500)\/"},
{"Message": "App_testing_4102012924am", "MessageTime": "\/Date(1334068533627-0500)\/"},
{"Message": "Kunal_testing_4102012924am", "MessageTime": "\/Date(1334067945510-0500)\/"},
{"Message": "Alert: Door Open", "MessageTime": "\/Date(1334066280963-0500)\/"}]
Fehle ich hier etwas in den Einstellungen. Der gesamte Code funktioniert einwandfrei, wenn der Dienst in dieselbe Domäne verschoben wird.
Ich schaute in ähnliche Post, konnte aber nicht funktionieren.
Ich hoffe, dass Sie auch Cross-Domain-Richtliniendatei hinzugefügt haben, hier überprüfen http://msdn.microsoft.com/en-us/library/cc197955%28v = vs.95% 29.aspx – Chandermani
Ja, das ist schon in der Wurzel –