How to call .sjs file from HTML?

624 Views Asked by At

I just started learning programming using MarkLogic. I followed documentation, created "sample.sjs" file like in below. https://docs.marklogic.com/guide/jsref/language#id_71272

xdmp.setResponseContentType("text/plain");
"hello"

How should I call this "sample.sjs" to display result in HTML? Or should I better include HTML code inside "sample.sjs" file?

1

There are 1 best solutions below

0
kcoleman On

Your SJS code must construct whatever content you want to return to the caller, including HTML. The content returned by your module becomes the response data.

There's a bit more robust example using JSON instead of HTML, here:

https://developer.marklogic.com/learn/sjs/http