HttpWrite
This function adds text to the output of the current HTML file of the HTTP interface.
Syntax
bool httpWrite ( string text )
Shortcut syntax
The following shortcut syntax is also supported (the space between the <* and the = is optional):
[html] <* = text *>
which is equivalent to:
[html] <* httpWrite(text) *>
Required Arguments
- text: the string of text to be added to the page's output.
Returns
Returns true if the text was added to the output buffer successfully, false otherwise.
Example
This sample resource page will output a random quote from a player using a function previously exported to http from a Lua script in the resource.
[html] <html> <head> <* = call ( getResourceFromName("ajax"), "start", getResourceName(getThisResource()) ) *> </head> <body> <b>Random quote:</b> <* httpWrite( call ( getThisResource(), "getRandomQuote" ) ) *> </body> </html>
The first httpWrite call (in shortcut syntax) adds the links to scripts generated by the ajax resource, enabling use of the getRandomQuote function.
The second httpWrite call writes the quote generated by the function to the HTML output.
See Also
These functions can only be used from within lua blocks in HTML pages hosted by the server
- httpClear
- httpRequestLogin
- httpSetResponseCode
- httpSetResponseCookie
- httpSetResponseHeader
- httpWrite