title: How to change a text value by requesting a PHP file thanks to AJAX? (Without refreshing the page)
body: <p>I'm learning AJAX and want to create a really simple web app to use my knowledge in the &quot;real world&quot;.</p>
  <p>I'm trying to calculte different percentages of a user input value, and make it appears on the webpage, without refreshing, thanks to AJAX.</p>
  <p>Here is my HTML form:</p>
  <pre><code>&lt;form id=&quot;warmupForm&quot; class=&quot;form&quot;&gt;
        &lt;label for=&quot;userWorkLoad&quot;&gt;Work load (in kgs)&lt;/label&gt;&lt;br&gt;
        &lt;input type=&quot;text&quot; name=&quot;userWorkLoad&quot; id=&quot;userWorkLoad&quot;&gt;
        &lt;button type=&quot;submit&quot;&gt;Calculate&lt;/button&gt;
      &lt;/form&gt; 
  
  &lt;div id=&quot;#output&quot;&gt;This is where I want the result to be shown with AJAX&lt;/div&gt;
  </code></pre>
  <p>Here is some of my PHP code, for you to get the idea:</p>
  <pre><code># Get the user input (work load in kgs)
  if (isset($_POST['userWorkLoad'])) {
      $workload = $_POST['userWorkLoad'];
  
      # Avoid JS hacking
      $workload = htmlspecialchars($workload);
  }
  
  # CALCULATION #
  # Calculate 55% of the work load (1st warm up set)
  $FirstWarmupSet = ($workload * 0.55);
  
  # Calculate 70% of the work load (2nd warm up set)
  $SecondWarmupSet = ($workload * 0.7);
  
  # First Warmup set #
  echo &quot;&lt;li&gt;Do 8 reps with &quot; . $FirstWarmupSet . &quot; kgs, then take 1 minute rest.&lt;/li&gt;&quot;;
  echo &quot;&lt;br&gt;&quot;;
  
  # Second Warmup set #
  echo &quot;&lt;li&gt;Do 5 reps with &quot; . $SecondWarmupSet . &quot; kgs, then take 1 minute rest.&lt;/li&gt;&quot;;
  echo &quot;&lt;br&gt;&quot;;
  // etc etc...
  </code></pre>
  <p>I'd like the different variables values from PHP to be shown in my &quot;#output&quot; div when the user click on the submit button.</p>
  <p>I've tried a lot of different things (AJAX without jQuery, AJAX with jQuery), but didn't manage to get what I want.</p>
  <p>I'm sure I'm doing something wrong, but I don't know what. I'm sure my PHP script is working, since I used it without AJAX without any problem.</p>
  <p>I would be very grateful if someone could help me on that.</p>