Check For File Update In Server Without Refresh - javascript

Here is what I am trying to do:
I want to read a file that has a number
I want to add one to that number, display it on the page, AND store it back to the original file
I want to be able to do this over and over without refreshing the page.
I have it figured out where I can do this, but only once. Once I hit a button, it adds one and displays the number, then stores it to the file, but I have to refresh to do it again. I have never used AJAX before so I'm wondering if this is even possible to do. In the most basic terms I want to be able to press a button and read a file that is constantly changing. Can it be done?

Related

HTML/JS - Asking the user to input a number, then displaying a different page on the same site based on the input

I'm using HTML, CSS and JS to build a website, the website has many functions and one important function is that i want to ask the user to manually enter a number from 1 to 40, then once the number is inputted the page changes to display a different page on the same website with information based on the inputted number. One way im thinking of doing is using a form then making the action be a switch statement for all 40 pages. But i'm struggling to find anything similar on Google or Youtube. And im unsure how to link the switch statement to my form, if that would even work. Any help would be appreciated!!
If you just want to redirect than you can add this line window.location.replace("<your link to page>"); in a function and call it when the user clicks the submit button. and make sure to pass the number to the page to process it. (this might be easier if you use php too, but won't be hard with javascript as far as i know)

How do I make specific inputs go into another .html file in the project?

I wanted to make specific inputs go into another part of a site (e.g. https://myexamplesite.com/anotherpartofit.html)
And also make those specific inputs be the ones that someone saved it in.
An example of what I think would work is: Get value from input 1 from /apartofit.html and put it in input 2 at /anotherpartofit.html and make it non-editable
If it needs to use a database, I would prefer if you could help me with firebase (Google's Database). But in my knowlege, it probably needs to use javascript, so I'll be tagging it, if it doesn't, let me know!
in visual studio or notepad or every offline web creating spaces you can't but if you buy a domain or simple , online site , you have to crate a page and get the link of that page then open another page create a button set the button's href to link of pervious page finally hit the button !

The new added field doesn’t show up when I reload the page

I am facing an issue and I don’t know how to resolve it.
I added a field on a webpage using JavaScript, ( when the user clicks on a button a new field should be added and it must be a static I mean it doesn’t suppose to be disappeared when move to another page or refreshing the page)the field appears but when I refresh the page it disappears.
Is there a solution for this?
Usually the local variables which are set by JS will be cleared when refreshing page, so what you can do is,
1) make use of LocalStorage API or
2) if you have a server, create some API calls, store the value in DB, if the user logs in from different browser, he can see the field.

Is it possible to load another page when you're creating a pdf with tcpdf?

I'm trying to change the page, when you are downloading a pdf. Otherwise you can download a lot of pdfs. I'm trying to make something against the spam.
What I got now: I create a id for a session. This session is named by idPDF. I create the idPDF by getting the current date and time. When you're creating the pdf, the idPDF will go to an online database. When the idPDF is found in the online database, then you're no longer able to create a pdf.
Then it will delete a part of the page and create a button with a php function isset. With this button you can create a new session and start creating a new pdf.
But I need to reload the page, before it is giving me this button. So how can I reload the page (that my page can check the id) or start a javascript function on the html page(fadeIn with jquery)?
Does anyone understand my question?
PS: For the output of the pdf, I'm using 'FD'
pps. I'm new with TCPDF
I solved it!
I used a jquery onclick function. It was that simpel.. First I had some problems with the required fields, but I changed it with a function that I used as a filter. I could load another page or button when the function returned true. With the button I could created another session.

Grails - Dynamic file upload without page reload

This is more of an approach issue than how-to.
I have a main form/document where user can dynamicaly attach/upload files using hidden iframe.
Each time user removes/adds a file, it is deleted/persisted to database by submitting an extra form to iframe. After that I do an ajax call and render a new gsp template containg updated list of files. All without page reload.
Then, if the form is successfully saved and validated, the uploaded files are linked to it. If not, they get eventualy cleaned up sometime later.
I am quite satisfied with the result but..
What I would like to know is if this is a good approach, since I always render a new template instead of DOM manipulation with javascript to provide the user the dynamic feel of file handling. Which I have seen most people do.
The one thing I can't seem to figure out is how to "localy" (hide it from user) remove the file without deleting it from database(without DOM). Atm, if the user deletes a file but decides not to save the main form, the file is gone anyway.
Thanks
I'm not entirely sure I understand the last part of your question, but I'm going to take a stab at it anyway. My assumption if that a user can say they want to delete a file, but not save the form, thus, the file doesn't get deleted. But when this happens, you're removing the file from the list anyway, and then it comes back on a page refresh.
If this is the correct understanding, I would recommend styling the representation of the file in some way that would indicate it is ready for deletion. Don't remove it completely. Gray it out, strikethrough, add an icon, something that says the system will delete this when you hit save.

Categories