我正在从 Jquery 调用 WCF Rest Service,如下所示。在我的 WCF 休息服务安全模式是传输。下面的代码返回“访问被拒绝”错误。
<script type ="text/javascript" language="javascript">
function GetRestData() {
var Guid = $('#txtUserGuid').val();
var CountryCode = $('#txtCountryCode').val();
var FromDate = $('#txtFromDate').val();
var ToDate = $('#txtToDate').val();
jQuery.support.cors = true;
$.ajax({
url: "https://localhost/OrderList/OrderListService.svc/RestService/GetOrderList?request=" + Guid + ";" + CountryCode + ";" + FromDate + ";" + ToDate,
type: "GET",
cache:false,
dataType: "json",
contentType: "application/json; charset=utf-8",
success: function(msg) {
alert(JSON.stringify(msg));
$('#result').html('JSON Greetings: ' + JSON.stringify(msg));
},
error: function(jqXHR, textStatus, errorThrown) {
alert(JSON.stringify(jqXHR) + ' ' + textStatus + ' ' + errorThrown);
$('#result').innerHTML = "Unavailable";
}
});
}
</script>