我想將markLogic用作文檔存儲 - 如果有人可以列出簡單的AJAX方法來訪問mL,我會非常高興。 我已經在我的PC上加載了mL - 我的本地主機指向Apache(WAMPserver)。 我從第三方網站(yahoo.com)上傳數據(json & xml),然後按摩它,我想用一個簡單的jQuery AJAX函數以mL爲單位進行存儲。請不要任何第三方軟件,如ROXY等使用jQuery AJAX與marklog進行交互
0
A
回答
5
您將首先需要爲您的數據庫引導REST服務器。從這裏開始:
http://developer.marklogic.com/learn/rest/setup#create-a-rest-api-instance
則可以跳過對CRUD的部分。
0
請確保您有REST服務,從Marklogic數據庫獲取數據:
curl --basic --user admin:none -i -X POST -H "Content-type: application/x-www-form-urlencoded" --data-urlencode module=/ext/invoke/test.xqy --data-urlencode vars='{"j":{"name":"John","bankAccounts":["Northern Bank","Fargo"]}}' http://ec2-18-217-208-58.us-east-2.compute.amazonaws.com:8003/LATEST/invoke
下面是我的index.html:
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8' />
<meta http-equiv="X-UA-Compatible" content="chrome=1" />
<title>Marklogic Ajax Test</title>
<meta name="description" content="Marklogic AJAX Test Client" />
<script src="http://code.jquery.com/jquery-1.10.2.js"></script>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
<script src="http://code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<script type="text/javascript" >
$(function() {
\t \t $('#submit').button();
\t \t $("#form").submit(function(e) {
\t \t \t var user = $('#user').val();
\t \t \t var password = $('#password').val();
\t \t \t var url = $('#url').val();
\t \t \t e.preventDefault();
\t \t \t $.ajax({
\t \t \t \t type: "POST",
\t \t \t \t url: url,
\t \t \t \t data: $("#form").serialize(),
\t \t \t \t beforeSend: function (xhr) {
\t \t \t \t \t \t xhr.setRequestHeader ("Authorization", "Basic " + btoa(user + ":" + password));
\t \t \t \t \t },
\t \t \t \t success: function(data)
\t \t \t \t {
\t \t \t \t \t alert(data); // show response from the php script.
\t \t \t \t },
\t \t \t \t error: function(data)
\t \t \t \t {
\t \t \t \t \t alert("Error: " + data);
\t \t \t \t }
\t \t \t \t });
\t \t });
});
</script>
</head>
<body>
Enter URL of REST service: <input type="text" name="url" value="http://ec2-13-58-46-47.us-east-2.compute.amazonaws.com/marklogic/LATEST/invoke " id="url" style='width:70em' /> <br/>
Username: <input type="text" name="username" value="admin" id="user"/> <br/>
Password: <input type="password" name="password" value="none" id="password"/> <br/>
<h1>Invoke REST service</h1>
<form id="form" method="post" enctype="application/x-www-form-urlencoded">
URI of xquery in module database: <input type="text" name="module" value="/ext/invoke/test.xqy"style='width:70em' ><br> \t
JSON input: <input type="text" name="vars" value='{"j":{"name":"John","bankAccounts":["Northern Bank","Fargo"]}}' style='width:70em'/> <br/>
<input id="submit" type="submit" value="invoke xquery">
</form>
</body>
</html>
添加到你的/ etc /httpd/conf/httpd.conf:
ProxyPass /marklogic/ http://localhost:8003/ <Location /marklogic/> ProxyPassReverse/ #ProxyHTMLEnable On SetOutputFilter INFLATE;proxy-html;DEFLATE #ProxyHTMLURLMap http://localhost:8003/ /marklogic/ #ProxyHTMLURLMap//marklogic/ </Location>
代碼已經過測試,但我沒有給你有效的密碼。您可能需要修改ProxyPass部分。
相關問題
- 1. JQuery Ajax不與MySQL進行交互
- 2. 使用jQuery與Alchemy.js進行交互SVG
- 3. 與jQuery進行PDF交互
- 4. 使用PHP,jQuery和Ajax進行交互式文件處理
- 5. 無法與使用jquery的jquery加載按鈕進行交互
- 6. Jquery與多個圖像進行交互
- 7. jQuery與下拉列表進行交互
- 8. 如何與使用ajax插入的對象進行交互?
- 9. 使用C#與Windows Update進行交互
- 10. 使用pywin32與Excel進行交互
- 11. 與C++進行交互
- 12. 如何使用jQuery與數據庫進行交互
- 13. Facebook靜態HTML iFrame - 使用JQuery與父級CSS進行交互?
- 14. 在Jquery $ .ajax()執行後,我可以使用XML進行交互嗎?
- 15. ProcessBuilder getOutputStream並與進程進行交互
- 16. 用戶無法與Seekbar進行交互
- 17. 與Android的Webview進行Javascript交互
- 18. jQuery/AJAX交互問題
- 19. 與沒有MFC的CMutex進行交互
- 20. 通過UIDocumentInteractionController與郵件進行交互
- 21. 如何與pynessus進行交互
- 22. 與維基百科API進行交互
- 23. 使用processBuilder執行shell命令並與它進行交互
- 24. WIF如何與[授權]進行交互?
- 25. 與客戶端軟件進行交互
- 26. java與payshield 9000進行交互
- 27. XCUITest與通知橫幅進行交互。
- 28. 如何從ruby與RVM進行交互?
- 29. CouchDB AJAX交互
- 30. 與Hibernate進行交互時出錯