JQuery / NTLM (CrossDomain ?)
Hello,
I want to request a REST api with JQUERY.
The Rest API is available with an NTLM authentication so I use crossdomain option.
I think that the issue is that I don't receive json data, i receive html data.
When I check on the server where is the REST api, I see in log file this
- <!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script>
function getInformations() {
var hostname = getQuerystring('hostname');
var servicedescription = getQuerystring('servicedescription');
$.ajax({
headers: {
Accept : "application/json",
},
type: "GET",
url: 'http://dldsd01/CGDMAPIAccess/restapi.ashx/domains/EDBCICTCGSROLE',
dataType: 'jsonp',
contentType: "application/json",
cache: false,
data: {
QUERY: 'BYCINAME',
CINAME: hostname
},
xhrFields: {
withCredentials: true
},
crossDomain: true,
success:function( data ) {
$("#informations").empty();
$.each( data, function( i, item ) {
console.log(i);
$( "<p/>" ).html("CI #<strong>" + item.CINAME + "</strong>").appendTo("#informations").hide().fadeIn(1000);
var ul = $( "<ul/>" );
$( "<li/>" ).html(item.CTCROLE + "-" + item.SUPPORTSCOPENAME + "-" + item.CTCNAME).appendTo( ul);
ul.appendTo("#informations").hide().fadeIn(1000);
})
},
error: function(ts) { alert(ts.responseText) }
})
}
function getQuerystring(key, default_) {
if (default_==null) default_="";
key = key.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
var regex = new RegExp("[\\?&]"+key+"=([^&#]*)");
var qs = regex.exec(window.location.href);
if(qs == null)
return default_;
else
return qs[1];
}
</script>
</head>
<body onload="getInformations()">
<div id="informations" />
</body>
</html>
Thank you in advance for your help.
Regards,
Samuel Mutel.