简体   繁体   中英

load file and write in xml or html?

I am curious if this is possible:

on the website:

  1. using jquery to get value from a html tag and store the value as a variable
  2. using ajax to call a file (xml, html or txt) on servside or external site for a php file
  3. define the current value in the xml html or txt file
  4. and add this value to the current value. = new value
  5. store this new value in the xml html or txt (saving the file on server...)

Q1. Is this achievable?

Q2. If so, what file is best used/supported? (php would be my very last alternative option) I prefer xml and html...

Q3. step 1 to 4 i can get to work - but step 5 i have totally no experience in. Anyone can guide me the right direction for writing those documents?

You cannot write the file directly in the server using javascript.

What you can do, for example, is send the updated data to a page in the server (sending a request to a PHP page, or a MVC endpoint, or whatever server-side technology you want to use) and then have the server code update the file using that data.

You can do this with AJAX (eg. using jQuery with $.post ) if you want it to happen in the background, or with a normal request (which will reload the page or take the user elsewhere depending on the server code).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM