33 */
44function setUpdateContainerContent ( updateContainerID , content ) {
55
6- var updateContainer = document . getElementById ( updateContainerID ) ;
6+ const updateContainer = document . getElementById ( updateContainerID ) ;
77
88 if ( ! updateContainer ) {
99 alert ( 'No UpdateContainer found on page with id ' + updateContainerID ) ;
@@ -23,7 +23,7 @@ function ajaxRequest( url, fetchOptions, updateContainerID ) {
2323 response => {
2424 // When the response arrives, we determine if it's a multipart response or a "regular" response.
2525 // If it's a multipart response, we assume each part corresponds to a container to be updated
26- var contentType = response . headers . get ( 'content-type' )
26+ const contentType = response . headers . get ( 'content-type' )
2727
2828 if ( contentType . startsWith ( 'multipart/form-data' ) ) {
2929 return response . formData ( ) ;
@@ -37,8 +37,8 @@ function ajaxRequest( url, fetchOptions, updateContainerID ) {
3737 responseData => {
3838 if ( responseData instanceof FormData ) {
3939 for ( const pair of responseData . entries ( ) ) {
40- var partName = pair [ 0 ] ;
41- var partData = pair [ 1 ] ;
40+ const partName = pair [ 0 ] ;
41+ const partData = pair [ 1 ] ;
4242 setUpdateContainerContent ( partName , partData ) ;
4343 }
4444 }
@@ -77,15 +77,15 @@ function ajaxUpdateLinkClick( url, updateContainerID ) {
7777function ajaxSubmitButtonClick ( button , updateContainerID ) {
7878
7979 // The form we are submitting is always the clicked button's containing form
80- var form = button . form ;
80+ const form = button . form ;
8181
8282 // The URL we'll be targeting is the form's action URL.
8383 // Just like with regular forms, deciding which button was actually clicked is based on the element name of the button.
8484 // Due to this The name of the button gets added to the request's query parameters below.
85- var url = form . action ;
85+ const url = form . action ;
8686
8787 // Get the values from the form to submit and wrap them in URLSearchParams for x-www-form-urlencoded
88- var params = new URLSearchParams ( new FormData ( form ) ) ;
88+ const params = new URLSearchParams ( new FormData ( form ) ) ;
8989
9090 // Since JS won't add the name of the clicked button to the request's parameters for us
9191 // (as is usually done by a regular form submit using an input type="submit"),
@@ -111,7 +111,7 @@ function ajaxSubmitButtonClick( button, updateContainerID ) {
111111 * Submits an observed field's form every time a change is observed
112112 */
113113function performSubmit ( form ) {
114- var data = new FormData ( form ) ;
114+ const data = new FormData ( form ) ;
115115
116116 // Add extra data to form if required submission.
117117 // We can use this to submit a subset of the form fields!
@@ -120,9 +120,9 @@ function performSubmit( form ) {
120120 // Obtain the form's action url for use when submitting
121121 const uri = form . getAttribute ( 'action' ) ;
122122
123- // var data = '3.1.1=0&3.1.3=200&3.1.5=0&3.1.7=200';
123+ // const data = '3.1.1=0&3.1.3=200&3.1.5=0&3.1.7=200';
124124
125- var xhr = new XMLHttpRequest ( ) ;
125+ const xhr = new XMLHttpRequest ( ) ;
126126 xhr . open ( 'POST' , uri ) ;
127127 // xhr.setRequestHeader('content-type','application/x-www-form-urlencoded')
128128 xhr . send ( data ) ;
0 commit comments