# simpleHTTPServer, saveStrings / ajax?

**URL:** https://discourse.processing.org/t/simplehttpserver-savestrings-ajax/32591
**Category:** Libraries
**Created:** [October 3, 2021, 9:41pm UTC](https://discourse.processing.org/t/simplehttpserver-savestrings-ajax/32591 "2021-10-03T21:41:22Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![rkdnson](https://avatars.discourse-cdn.com/v4/letter/r/cc9497/32.png) [@rkdnson](https://discourse.processing.org/u/rkdnson)
#### Post date: [October 3, 2021, 9:41pm UTC](https://discourse.processing.org/t/simplehttpserver-savestrings-ajax/32591/1 "2021-10-03T21:41:22Z")

</div>

Hello everyone, I am using the [SimpleHTTPServer by transfluxus.](https://github.com/transfluxus/SimpleHTTPServer) It works great, but I am have some general HTTP questions.

I want to host a local site that has constantly updating information.

This is my current workflow:

```auto
//index.txt file has the base formatting for the page as well as "?REPLACE?" keywords
LoadStrings(index.txt)
//Find and replace the specified keywords.
SaveStrings(index.html, data)

```

Because the information is constantly changing, I set the page to reload after x seconds. This causes the browser to every so often lose the file. In the browser, index.html is completely blank.

I am assuming this is because I am saving a new file every draw cycle and if it ever gets out of sync the browser will lose all data as well as the function to refresh.

So, is there a way I can write a function to only modify the file after a certain point? Or, leave index.html alone and instead write to a completely different html file that gets served instead? This way the function to refresh would always be there?

Separately, is there a way of triggering a client’s browser to refresh only when the server has new information?

Thanks!

---

<div class="post-metadata">

### Author: ![rkdnson](https://avatars.discourse-cdn.com/v4/letter/r/cc9497/32.png) [@rkdnson](https://discourse.processing.org/u/rkdnson)
#### Post date: [October 4, 2021, 3:48am UTC](https://discourse.processing.org/t/simplehttpserver-savestrings-ajax/32591/2 "2021-10-04T03:48:40Z")

</div>

Solving my own question, I was able to do everything with AJAX requests. Took me a while to understand, and I still don’t understand fully, but this seems to be the best route for this problem.

More information on AJAX in the SimpleHTTPServer Library, [here](https://github.com/transfluxus/SimpleHTTPServer/blob/master/examples/EchoJSON/data/index.html).
