Example Code

Response to AJAX HTTP Request with LabVIEW

Code and Documents



With LabVIEW web services, we can respond to AJAX methods by utilizing the LabVIEW Web Services API and the Write response method.  This is a fast and easy method to create dynamic web pages utilizing the LabVIEW web server.


This short example demonstrates how we can use AJAX methods to get the windows login name of a particular user.  AJAX sends an HTTP request, calling a LabVIEW web method that responds with the login data.  We then set a text input field to the user name.

Steps to Implement or Execute Code

  1. Download and unzip the attached file
  2. Start the LabVIEW web server by right-clicking the 'WindowsLoginAJAX' web service and select Application Web Service -> Publish
  3. Using a web browser, type the following url: http://localhost:8001/WindowsLoginAJAX
    This will navigate you to the home page
  4. Select the 'Get Login' button: this will run the ReturnWindowsLogin web method



LabVIEW 2013 or greater

Windows OS

Additional Images or Video

Snippet of javascript/ajax function embedded in html page


Web service snippet for get windows user name:


Cole R.
National Instruments
Software Engineer

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.