简体   繁体   English

加载文件并以xml或html格式编写?

[英]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 使用jquery从html标签获取值并将该值存储为变量
  2. using ajax to call a file (xml, html or txt) on servside or external site for a php file 使用Ajax在Servside或外部站点上为php文件调用文件(xml,html或txt)
  3. define the current value in the xml html or txt file 在xml html或txt文件中定义当前值
  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...) 将此新值存储在xml html或txt中(将文件保存在服务器上...)

Q1. Q1。 Is this achievable? 这可以实现吗?

Q2. Q2。 If so, what file is best used/supported? 如果是这样,最好使用/支持哪种文件? (php would be my very last alternative option) I prefer xml and html... (PHP将是我的最后一个替代选择)我更喜欢xml和html ...

Q3. 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? 第1步到第4步我可以开始工作-但是第5步我完全没有经验。有人可以指导我正确的方向写那些文件吗?

You cannot write the file directly in the server using javascript. 您无法使用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. 例如,您可以做的是将更新的数据发送到服务器中的页面(将请求发送到PHP页面,MVC端点或要使用的任何服务器端技术),然后获取服务器代码使用该数据更新文件。

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). 如果您希望它在后台发生,则可以使用AJAX来执行此操作(例如,将jQuery与$ .post一起使用),也可以使用常规请求(根据服务器代码将页面重新加载或将用户带到其他地方)进行处理。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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