我正在尝试使用odata从crm返回结果集。我是新手。我希望有一个asp.net页面显示数据网格中的值。我收到错误odata执行错误弹出窗口。如果我输入正确的服务器和查询字符串,它总是失败..任何有关如何正常工作的建议
function ExecuteQuery(ODataQuery) {
//var serverUrl = Xrm.Page.context.getServerUrl();
var serverUrl = "https://server.server.com"; //would be the real server
// Adjust URL for differences between on premise and online
// if (serverUrl.match(/\/$/)) {
// serverUrl = serverUrl.substring(0, serverUrl.length - 1);
// }
alert("test");
var ODataURL = serverUrl + "/XRMServices/2011/OrganizationData.svc" + ODataQuery;
$.ajax({
type: "GET",
contentType: "application/json; charset=utf-8",
datatype: "json",
url: ODataURL,
beforeSend: function (XMLHttpRequest) {
XMLHttpRequest.setRequestHeader("Accept", "application/json");
},
success: function (data, textStatus, XmlHttpRequest) {
//
// Handle result from successful execution
alert("success");
//data.d.results
},
error: function (XmlHttpRequest, textStatus, errorObject) {
//
// Handle result from unsuccessful execution
//
alert("OData Execution Error Occurred");
}
});
}
<script type="text/javascript">
ExecuteQuery("the query would go in here);
</script>