I want to give large data from HTML to javascript.

Asked 2 years ago, Updated 2 years ago, 62 views

I'm studying HTML5+SpringBoot

I passed the data from HTML to javascript as follows:

th:onclick=" | show ('${test.data1}', '${test.data2}'); |

If the data is small, the value will be passed without any problems.
(I was able to check the js file by breaking it.)
If the size is as large as the image data, the following error will appear:

Is there any way to pass large data to the javascript side?

SyntaxError:unterminated string literal

jjs file

function show(data1,data2){
}

javascript html5

2022-09-30 21:17

1 Answers

If you look at large files such as image data, embedding them in HTML (whether JavaScript, HTML, or Base 64) delays loading the entire page, so you should prepare a separate file or API and pass the reference to them.

Also, SyntaxError: unterminated string literal is an error caused by one of the following and does not appear to be a size issue.

To correct this error, check the following:

  • Starting and ending the quart (single or double) for string literal.
  • The string literal is escaped correctly.
  • String literal is not divided into multiple lines.

https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Errors/Unterminated_string_literal


2022-09-30 21:17

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.