The HTTP API > The HTTP API > MMHttp.getTextCallback() |
Description
Retrieves the contents of the document at the specified URL and passes it to the specified function.
Arguments
callbackFunc, URL
| The first argument is the name of the JavaScript function to call when the HTTP request is complete. | |
| The second argument is an absolute URL on a Web server; if "http://" is omitted from the URL, it is assumed. |
Returns
An object that represents the reply from the server. The data property of this object is a string containing the contents of the document.
Example
The following code populates a form field with the text returned by the MMHttp.GetTextCallback() function or shows an error message if the function returns an error:
var requestID = MMHttp.getTextCallback("httpCallback", ¬
"www.dreamcentral.com/index.html")
function httpCallback(requestID,reply) {
if (reply.statusCode == 200) {
document.theForm.docContents.value = reply.data;
}else{
alert("Request #: " + requestID + "returned the following ¬
error: " + reply.statusCode);
}
}