I'm trying to hit the rest API from a website using jQuery. Since I ran into a cross site scripting issue, I'm using jsonp as the datatype. Although I'm seeing a 200 status getting returned, there seems to be an issue with reading the data. I tried changing the contentType around to several other options, but they don't seem to work.
Does anyone know a better javascript method for this or have any idea on what I'm doing wrong?
Error message
SyntaxError: expected expression, got '< <?xml version="1.0"" etc
Here's the jquery code snippet.
var jamfAPI = 'https://ourjamfurl /JSSResource/computers/match/useridhere;'
function setHeader(xhr) {
xhr.setRequestHeader('username', 'theusername'); xhr.setRequestHeader('password', 'thepassword'); } $.ajax({
url: jamfAPI,
type: "POST",
dataType: "jsonp",
processData: false,
contentType: "application/json",
beforeSend: setHeader,
success: function () {
alert('success');
},
error: function (xhr, ajaxOptions, thrownError) { alert(xhr.status); alert(xhr.responseText); }, });