O'Reilly logo

Learning WML, and WMLScript by Martin Frost

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

loadString — Fetch a string from a URL

Usage

URL.loadString(url, type)

url : String

type : String

Description

Attempts to fetch the text resource pointed to by the URL url. The MIME content type of the resource must match type, and type must be a text type (must start with text/). If successful, the resource is converted to a string and returned. If the load fails, or the type of the resource doesn’t match type, an integer error code is returned. This code depends on the URL scheme. For HTTP, it’s an HTTP response code.

Returns invalid if either argument can’t be converted to a string. Returns invalid if type isn’t a text type or specifies more than one content type.

Examples

URL.loadString("http://wap.net/cgi-bin/word.cgi", "text/plain")

returns string "EXAMPLE"

URL.loadString("nonexistent", "text/plain")

returns integer 404

URL.loadString("foo", "text/*")

returns invalid

URL.loadString("foo", "image/wbmp")

returns invalid

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required