Best practise to load javascript settings from server
Miltos Tereres
Ranch Hand
Joined: Sep 04, 2009
Posts: 32
posted
0
Hello guys....
I am developing an application where the user inputs some data to a table.
The data is appended using javascript+jquery... Code places some hidden fields and populates a table....
And i have this code at an external javascript file...
The problem is that when i want the user to retrieve what he has put ,populating the table using server side script seems a waste of time and writing code again which i should change if i change something in the javascript...
So i thought to get a JSON response from my server and then call the javascript method to populate the table....
The problem is that i should place the javascript code in my page and not at an external file ,because at an external it wont be parsed...
Also i would like to get advices how to solve this problem....
thank youu
This message was edited 1 time. Last update was at by Bear Bibeault
Bear Bibeault
Author and opinionated walrus
Marshal
Miltos Tereres wrote:So i thought to get a JSON response from my server and then call the javascript method to populate the table....
The problem is that i should place the javascript code in my page and not at an external file ,because at an external it wont be parsed...
Sorry, not understanding the issue. If you include external JS, it is parsed exactly the same as if it were on the page.
P.S. English sentences end with a single period -- not multiple periods.
If the page is a jsp and i include a javascript i cant use jsp tags etc in my js.
Only in the page.
So cant put initial parameters.
This message was edited 1 time. Last update was at by Miltos Tereres
Eric Pascarello
author
Rancher
Joined: Nov 08, 2001
Posts: 14857
posted
0
Include the part of the JavaScript code in the page that needs to be customizable. Include the rest of the code in the external JavaScript file. Both can interact.
Or you can make a backend page that produces a custom js file for that user.