My setup is like this, both servers are in different domains.
- SharePoint Foundation 2013 with an HTML/JavaScript app, hosted on Office365 by Microsoft.
- Windows Server 2012 with Dynamics NAV 2013, hosted on Azure by Microsoft.
What I like to do is to call a NAV 2013 oData webservice through jQuery. I have checked that my webservice is accessible from the browser, and I do get a successfull response.
But when I try calling it from my app in SharePoint I do get an error saying.
SyntaxError: syntax error
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
This is my jQuery code:
var call = $.ajax({
url: 'http://url:port/DynamicsNAV70_Instance/odata/MyService',
type: "GET",
crossDomain: true,
username: "username",
password: "password",
dataType: "jsonp",
headers: {
Accept: "application/json;odata=verbose"
}
});
call.done(function (data, textStatus, jqXHR) {
console.log(data.d);
});
call.fail(function (jqXHR, textStatus, errorThrown) {
console.log("Call failed. Error: " + jqXHR.statusText);
});
I have discovered that ´jsonp´ does not work well with XML response, but this call should return json shouldnt it?
Also, in FireBug I can actually see the complete XML returned from the service, and it is completly correct. So my app do get the correct XML, but looks like it is a parsing error?
I also thoughyt about enabling CORS (http://enable-cors.org/index.html) on my Dynamics server, but not sure how I can do this?