Data transfer from one HTML page to another - javascript

When creating a technical site, I faced the need to transfer data and save it in a file. I am making a website in Django. In models I create input data. I receive these data in HTML and, if necessary, the user changes them and JS performs the necessary calculations, the results of which are sent to the same page. It is possible to do a lot of analytical work on outgoing data (build graphs, calculate a loan, calculate various project risks). I prefer to create several pages so as not to fill one. All pages have already been built. There was a problem of this nature: On the main page, JS did his job but I do not know how to access this data on other pages. Is there a solution to write a JSON string to a file or send them to Django model (update static data). I read a lot and looked for solutions, but I could not figure it out until the end. Maybe someone knows the solution.
Thank you in advance.
If need more information, please let me know.
This is my first request for help, so please don’t be strict if I cannot ask correctly.

Writing to a temporary or holding table in a database might be a solution. You would be able to fetch the data as needed when a new page loads.
There is probably a better solution though.

Related

Share data without database

I have this web application that gets and displays data from SAP, but i need a way (maybe a JSON file?) to share some data between different users, with the possibility to modify these same data for each user (even at the same time), without a database. There will be really small data and few users, and what i would write is simple data that tells me who is online in that moment. How can i do? I'd like to know if exist an easy solution to share these really small and simple data. I'm using React with no back, because i'm taking all the data i need from SAP. Clearly, i'm a beginner. All advice is welcome.
If you talking about some prototype like MVPs, I think JSON files would be best.
However, consider to work also that you can work with Local Storage.
You could use LocalStorage, SessionStorage or IndexedDB, but the last option is an in-browser database. Maybe LocalStorage is your solution.

Basic WebApp Questions

I am currently thinking about coding my first webapp.
I would say i have beginner to intermediate coding skills in html,css,js,jquery node,sql and monogodb.
The problem is that i do not really know how to achieve my goal.
My goal is to built a responsive single page website, which gets the stock price from an api and display it on one card. Furthermore the user should be able to click on the plus button and add another card with an stock index he chose from a choosing form option.
Now what want to know is:
Is this an example for choosing a js framework like react, vue etc. and how can I accomplish my goal ?
I coded the api get request etc. in node and was able to print everything I want into the console log. How do I do the same thing but displaying it on my html page ?
How can I create these cards which are automatically getting added to the homepage ?
How can I save the data for each individual card? (especially without a login procedure...)?
I know these are quite easy questions but I really want to learn how to do it.
Please check the images below.
(check:
I would say try to use your existing skills to achieve your goals. When you run into problems you cannot solve or problems that could be solved by a specific framework such as react, try using them. It's better to understand what these frameworks are doing before you rely on them for every development.
You need to use an http framework like express to return your api values from node js to a web client.
Needs more info but as you're already talking about component based libraries, a good approach would be to keep the cards in a json array and render your page from that. If you are persisting the card data in a database you will also may want to render them server side as the page is loaded using a server side technology like node.
To keep things simple, you can store the info client side using something like localStorage or indexeddb. If you want to store something on the server side, you will need to introduce a way of identifying the user.

How do you make a single-page-application (SPA) searchable from SharePoint?

We are working on a single-page-application (SPA) developed in ASP.NET MVC using knouckout and a wealth of other libraries. Routing will be done in front-end, maybe we will use crossroads.js. A lot of information is presented in virtual grids using slickgrid.js. All data is fetched from backend using AJAX.
Now, if you want to crawl and index such a site from SharePoint, how would you go about that? If you just load the main page with no javascript, it is almost empty.
Update
After more investigation into this issue, I have concluded that there are at least two possible solutions to this kind of problem.
Possible solution 1: Render HTML
This approach would involve detecting that a SP crawler is crawling your site, and then return static HTML pages for the crawler. PhantomJS could possibly be used for this. There are however several uncertain aspects to this solution, and I suspect that it would involve a lot of work.
Possible solution 2: Import data into SharePoint
As so clearly described by Josh below, you could import the data that you want crawlable into SharePoint. Then SharePoint can be configured to crawl the data, and the data is not Javascript dependant anymore as it is inside SharePoint. I think this is the best and easiest solution and will mark Josh answer as the accepted answer.
While I see that this question is getting a lot of close requests, I did run across this very question on a previous project. Sharepoint won't be able to index the page that data is manipulated on via your SPA, but inside SP, you can connect external data sources into the search service, thus exposing the data inside the SPA. You would then write custom search results tied to the content type of the data exposed in order to make the results a bit more friendly than just a data row. You might create an entry point in your SPA that can take in a URL with a parameter so you can send the user from the search results to the SPA in one shot.
There are a lot of interconnected concepts to this solution, so I'd suggest looking into connecting external data sources and adding them to the crawled index of SP. Then, create a content type out of the exposed objects. And finally, add a custom search result template for the content type. MSDN will be your friend on this and so will your SP administrator.

How to send static HTML to database via PHP

I am working on a simple "task list" project right now. I have built the I have so far using jQuery and Javascript to insert/delete/manipulate the "tasks". Because all of the elements are created/removed/changed in the DOM, every time the page is refreshed, all changes to the list are lost. I dont want to use a caching system because the aim is to create a system that can be accessed from multiple devices. I would like to set up some sort of PHP database that would allow me to create user profiles and have each users "tasks" separated.
I am familiar with Wordpress so I'm thinking I could use that and its user profile system to accomplish what I need. The issue I have is that I cant find any information as to how I could send the changes that were made to the DOM to a separate database entry associated with each user.
My strategy from there (unless anyone could suggest a better method of storing the data) would be to essentially make a copy of a set section of the raw HTML and post that to the database entry when the user hits a "save" button. Each time they log in, the most recent HTML would be loaded into the DOM as a starting point. They could then make the changes they desire, hit "save" before leaving the site and the cycle would repeat.
I am new to development side of things, so I could be making this way harder than it needs to be. Any links to topics similar to this, suggestions, advice would be appreciated. Im not asking for an in-depth how-to guide (though that would be nice) but to just be pointed in the right direction.

MVC: Pass HTML template in JSON response rather than separate resource?

I'm planning to write a web app using either Backbone or Angular. We want to push "widgets" from the server to the client (i.e. semi-complicated, dynamic but largely autonomous UI elements... something maybe like the popular TodoMVC app). So we'll need to send over a template, some javascript (controllers etc.), probably CSS, and JSON data (models).
We're debating how to send over all the information. How much can be, and what should be encapsulated in the JSON?
Is it possible to create files out of data passed over? i.e. could we pull out CSS and apply the rules to our document? I believe it would be easier to run javascript passed over this way.
I'm under the impression that being able to cache the template is important... does that require loading it as a (separate) resource rather than as part of some huge JSON object?
As for CSS, it needs to be loaded before inserting into the DOM (so we don't want just a promise). Would it make sense - or even be possible - to pass our CSS rules in the JSON and extract them somehow?
EDIT: to more fully describe what I'm working with, I'm focusing only on the front-end. The back-end can be customized to send over resources however we want - they'll optimize that depending on what the front-end needs. Our backend stack includes MongoDB, Tapestry, ActiveMQ.
The payload that needs to get sent over will be all the resources necessary to push something like a Mac Dashboard Widget or Windows Gadget into the browser. So HTML, CSS, Javascript, data will all get sent over. We want things to be snappy and minimize server requests as much as possible, as some of these payloads may get to be somewhat large.
Your questions are rather vague and the answers can change by coding on a different build platform. Your chosen application design can also impact the best practices to follow for implementing X type of application to X device(s). There's more than one way to skin a cat ya know.
What information are you sending over? Is it a lot of raw data arrays? Is it more document based where XML could be more beneficial? You'll need to work with your DBA if the data is stored in a repository and you'll be querying it. Will you need to write code to format your data or will the DBMS output it in the format you need?
What do you mean the CSS needs to be loaded before being inserted? Everything loads in the order you specify so making sure your CSS loads at the proper time shouldn't be an issue. If you're using ASP.NET, you can also use a SSM (style-sheet manager) to serve your CSS and only load whats required. SSM's are great if you have a lot of style-sheets to serve.
A lot of the questions you asked will be answered as you get further into the design phase. In order to get some solid answers and not just speculation on what is the best method, you will need to publish a lot more details than this. Any answers at this point shouldn't carry much weight in your decisions. They certainly wouldn't mine.

Categories

Resources