-
Notifications
You must be signed in to change notification settings - Fork 182
Fetch Jingo pages via Ajax
Claudio Cicali edited this page Dec 28, 2015
·
1 revision
With a small set of configuration options, Jingo can serve stripped down version of the wiki pages via an Ajax call. The use case here, is where you want to embed a page inside an existing one using content coming from Jingo. The following example will use jQuery but you can of course any library you want, provided that it (or you in its behalf) passes to jingo the x-requested-with: XMLHttpRequest
HTTP header while requesting the page (jQuery should provide it automatically).
First of all, set Jingo to provide the necessary CORS headers (take a look at the README for the details).
Now you can do something like:
<div class="content"></div>
<script>
$.ajax({
url: 'http://myjingowiki.org/wiki/OneInterestingWikiPage',
headers: {
"X-Requested-With": "XMLHttpRequest"
}
})
.done(function (html) {
$('.content').html(html);
});
The /search endpoint is also enabled, so if you want you can also send search requests.