JavaScript Engine: XMLHTTPRequest example

Note: This topic applies to Web - HTTP/HTML Vuser scripts written in C only.

VuGen's JavaScript Engine enables you to include JavaScript code in a Vuser script. For details on the JavaScript Engine, see Using the VuGen JavaScript engine.

The example below shows how you can use a JavaScript XMLHTTPRequest object in a Web(HTTP/HTML) Vuser script. In this example, the XMLHTTPRequest object enables the Vuser to download a stock quote from finance.example.com, and then to save the value to a parameter for future use.

The script section below shows a web_js_run function that has been inserted into a Vuser script. The web_js_run function includes a reference to a file called XMLHTTPRequest_sync_sample.js. This file contains the JavaScript code that executes the XMLHTTPRequest function.

The contents of the XMLHTTPRequest_sync_sample.js file are shown below.

  • For additional examples of code used with the JavaScript Engine, see the Function Reference (select the relevant version).
Back to top