0
我有一個跨域WCF。我已經在該服務上實施了CORS。如何從JQuery Ajax調用跨域WCF服務參數
如果該方法沒有任何參數,那麼我可以使用JQuery Ajax調用它。
但問題是,如果方法有任何參數,那麼在JQuery Ajax調用之後會發生一些錯誤。
$.support.cors = true;
$.ajax({
url: servicePath,
crossDomain: true,
type: 'POST',
async: false,
cache: false,
data: '{"name": "xyz"}',
contentType: "application/json; charset=utf-8",
dataType: 'json',
processData: true,
success: function (response) {
alert('s');
},
error: function (error) {
alert(error.status + ' : ' + error.statusText);
}
})
是您的服務的一個webapi?你可以傳遞參數在URL中,m lik yourservce.svc/parameter1/parameter2? –
它不是webapi。這是wcf應用程序。方法類型是'post'。 – Ayan
,因爲您可以在不帶參數的情況下到達您的端點,也許此鏈接可以幫助您:http://stackoverflow.com/questions/3876784/calling-wcf-service-with-jquery-and-parameters –