MarkLogicRESTJavaScript
有没有人能举一个简单的例子来使用JavaScript/JQuery从Marklogic数据库读取数据?简而言之,作为一个快速POC,您可能需要做以下几件事: -搜索文档(返回搜索结果) -获取一个或多个文档 当然,你可能想做更多的事情,但是以上这些让你开始了 我将从本文档开始,并遵循两个主要链接。1将为您提供实际的端点,另一个将是开发人员指南(带示例) 在所有情况下,您访问的HTTP资源都与其他HTTP资源一样,因此请举一个小例子: 对含水文档的完整数据库进行word查询: 以下两个示例是从本文重构的: 异步Javascript:MarkLogicRESTJavaScript,javascript,jquery,marklogic,Javascript,Jquery,Marklogic,有没有人能举一个简单的例子来使用JavaScript/JQuery从Marklogic数据库读取数据?简而言之,作为一个快速POC,您可能需要做以下几件事: -搜索文档(返回搜索结果) -获取一个或多个文档 当然,你可能想做更多的事情,但是以上这些让你开始了 我将从本文档开始,并遵循两个主要链接。1将为您提供实际的端点,另一个将是开发人员指南(带示例) 在所有情况下,您访问的HTTP资源都与其他HTTP资源一样,因此请举一个小例子: 对含水文档的完整数据库进行word查询: 以下两个示例是从
function httpGetAsync(theUrl, callback)
{
var xmlHttp = new XMLHttpRequest();
xmlHttp.onreadystatechange = function() {
if (xmlHttp.readyState == 4 && xmlHttp.status == 200)
callback(xmlHttp.responseText);
}
xmlHttp.open("GET", theUrl, true); // true for asynchronous
xmlHttp.send(null);
}
httpGetAsync("http://localhost:8000/LATEST/search?q=water", function(d){window.alert(d)});
$.get(
"http://localhost:8000/LATEST/search",
{q : "water"},
function(data) {
alert('page content: ' + data);
} );
jQuery:
function httpGetAsync(theUrl, callback)
{
var xmlHttp = new XMLHttpRequest();
xmlHttp.onreadystatechange = function() {
if (xmlHttp.readyState == 4 && xmlHttp.status == 200)
callback(xmlHttp.responseText);
}
xmlHttp.open("GET", theUrl, true); // true for asynchronous
xmlHttp.send(null);
}
httpGetAsync("http://localhost:8000/LATEST/search?q=water", function(d){window.alert(d)});
$.get(
"http://localhost:8000/LATEST/search",
{q : "water"},
function(data) {
alert('page content: ' + data);
} );
如果您需要更多关于MarkLogic和REST的特定功能的指导,包括转换文档等,请发布更具体的需求,我们可以在上面进行扩展。如果你没有具体的细节,至少给出一些问题陈述,这样我们可以帮助你找到正确的方向。有很多很多端点-了解用例的一般概念将有助于我们缩小您的范围。简而言之,作为快速POC,您可能需要做以下几件事: -搜索文档(返回搜索结果) -获取一个或多个文档 当然,你可能想做更多的事情,但是以上这些让你开始了 我将从本文档开始,并遵循两个主要链接。1将为您提供实际的端点,另一个将是开发人员指南(带示例) 在所有情况下,您访问的HTTP资源都与其他HTTP资源一样,因此请举一个小例子: 对含水文档的完整数据库进行word查询: 以下两个示例是从本文重构的: 异步Javascript:
function httpGetAsync(theUrl, callback)
{
var xmlHttp = new XMLHttpRequest();
xmlHttp.onreadystatechange = function() {
if (xmlHttp.readyState == 4 && xmlHttp.status == 200)
callback(xmlHttp.responseText);
}
xmlHttp.open("GET", theUrl, true); // true for asynchronous
xmlHttp.send(null);
}
httpGetAsync("http://localhost:8000/LATEST/search?q=water", function(d){window.alert(d)});
$.get(
"http://localhost:8000/LATEST/search",
{q : "water"},
function(data) {
alert('page content: ' + data);
} );
jQuery:
function httpGetAsync(theUrl, callback)
{
var xmlHttp = new XMLHttpRequest();
xmlHttp.onreadystatechange = function() {
if (xmlHttp.readyState == 4 && xmlHttp.status == 200)
callback(xmlHttp.responseText);
}
xmlHttp.open("GET", theUrl, true); // true for asynchronous
xmlHttp.send(null);
}
httpGetAsync("http://localhost:8000/LATEST/search?q=water", function(d){window.alert(d)});
$.get(
"http://localhost:8000/LATEST/search",
{q : "water"},
function(data) {
alert('page content: ' + data);
} );
如果您需要更多关于MarkLogic和REST的特定功能的指导,包括转换文档等,请发布更具体的需求,我们可以在上面进行扩展。如果你没有具体的细节,至少给出一些问题陈述,这样我们可以帮助你找到正确的方向。有很多很多端点——了解用例的一般概念将有助于我们缩小您的范围