Defining Calls to JavaScript Functions using a JavaScript Library Interface
- Updated2024-05-31
- 2 minute(s) read
Defining Calls to JavaScript Functions using a JavaScript Library Interface
To call JavaScript functions in your web application, define calls to the JavaScript functions using a JavaScript Library Interface (JSLI) document.
To create and configure a JSLI document, complete the following steps:
-
On the
Project Files tab, add a JSLI to a web application component or library component in your project.
A JSLI document appears in your web application.
-
Define the prototype for the JavaScript function you want to call. A defined call to a JavaScript function in a JSLI is called an
entry point.
-
In the JavaScript global form field, enter the name of the JavaScript function you want to call. The name you enter must exactly match the function name in the JavaScript code. You must specify all functions relative to the global scope. Use dot notation to refer to nested objects. For example, if you want to call the absolute function abs in the object Math, you must specify
Math.abs in the JavaScript global form field.
Note The JavaScript global form field is case sensitive.
- Click Add function to create an entry point. The default entry point name is created from the JavaScript global.
- Click Add parameter.
-
On the
Item tab, specify the parameter name, data type, and JavaScript representation.
Consider the following information when you add parameters to your prototype:
- You can choose any name for the parameters you add to a JSLI document, but you must add them in the same order as they appear in the JavaScript function.
- The parameter and return data types you specify in the JSLI document must match the parameter and return data types in the JavaScript function.
- The parameter in the top position in the JSLI document is always the return type.
-
In the JavaScript global form field, enter the name of the JavaScript function you want to call. The name you enter must exactly match the function name in the JavaScript code. You must specify all functions relative to the global scope. Use dot notation to refer to nested objects. For example, if you want to call the absolute function abs in the object Math, you must specify
Math.abs in the JavaScript global form field.
- Repeat step 2 to create as many entry points as you need for your project.
Related Information
- Waiting for Asynchronous JavaScript Operations to Complete in a Web Application
Use asynchronous JavaScript code to wait on tasks or requests while the rest of the code in your WebVI continues to execute.
- Debugging JavaScript Library Interfaces
Solve common problems that may occur when configuring and using JavaScript Library Interfaces (JSLIs).
- Preparing Your Code For Use With a JavaScript Library Interface
Create wrapper code, if necessary, to make your JavaScript functions compatible with the JavaScript Library Interface (JSLI).
- JavaScript Resources
Research JavaScript concepts using NI-recommended resources.