Auto updating client?

So today I got bored, and I decided to mess with my Arduino Yun. I made some code for the client that looks like this

  if (client) {
    String command = client.readString();
    command.trim();      
    Serial.println(command);
   
    if (command == "test") {

      
     
      client.print("Working!");

    }

    
    client.stop();
   
  }

 
}

is there a way so I can make it so the website automatically updates a number, e.g. a sensor value ect? If I try to do so, the website is blank unless if the client.stop() is there and it only reads 1 value from the sensor.

Hello,
can you post the entire code?

Take a look here: http://scuola.arduino.cc/courses/lessons/cover/zzdeJ3m
it is a good example to do what you want to do.

Angelo9999:
Hello,
can you post the entire code?

Take a look here: http://scuola.arduino.cc/courses/lessons/cover/zzdeJ3m
it is a good example to do what you want to do.

Here is the code:

#include <Bridge.h>
#include <YunServer.h>
#include <YunClient.h> 
 
YunServer server;
 
void setup() {
  Bridge.begin();
  server.listenOnLocalhost();
  server.begin();
}
 
void loop() {
  YunClient client = server.accept();
 
  if (client) {
    String command = client.readString();
    command.trim();
    if (command == "test") {
      int val = analogRead(A1);
      client.print(val);
    }
    client.stop();
  }
 
  delay(50);
}

The code is the exact same thing that I put earlier. What I want to do, is I want it to post my PING sensor values, without having to refresh the page, since the values don't automatically update.

You can do it with some Javascript code, here some info: