-1

I have two JS files. First file contains a function obtains some data (particularly, my function gets state of AbstractJavaScriptComponent which is just a String, but I think it's not important). And I want to send this data to another JS file (or make it accessible in that file in any way).

com_company_htmlcontent_web_screens_JsData = function() {
    // this value is what I want to send
    document.getElementById('myButton').value = this.getState().xhtml();
    this.onStateChange = function() {
        e.innerHTML = this.getState().xhtml();
        alert("on State changed is called"); // but this inner function is not called
    }
}

Are there any ways to make it possible?

Dmitry
  • 73
  • 2
  • 11

1 Answers1

0

Can you just send it with GET? Just pass the thata in URL that will switch you to the other file with js in it, then grab the data from it.

I don't really see the point of that action tbh. Can you state, what you want to archive?

If you just want to run some script that doing something with data given, and you dont want to change files you can send this data with Ajax.

fsn
  • 549
  • 3
  • 11
  • The first js file is the connector to the server side. The second js file is the widget and connector to the client side. My goal is to send data from backend to frontend in VAADIN module. I use https://vaadin.com/blog/-/blogs/vaadin-7-loves-javascript-components guide. In VAADIN, I've created the frame with custom HTML page. I want to get data from DB via java backend to send formatted JSON to my custom HTML page, which logic is encapsulated into the second js file. – Dmitry Mar 03 '16 at 21:20