title: How can I call a JavaScript function through html button?
body: <p>I want from the html component part, call a JavaScript file to run a command, clicking on a button.</p>
  <p>But when I click the button nothing happens:</p>
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
    &lt;meta charset=&quot;utf-8&quot;&gt;
  
  &lt;/head&gt;
  &lt;body&gt;
  
  &lt;p id=&quot;counter&quot;&gt;Loading button click data.&lt;/p&gt;
  
  
  &lt;button  id=&quot;buttonForScraping&quot;&gt;begin to scrape!&lt;/button&gt;
  &lt;script&gt;
    function startScrape(){
      jQuery.ajax({
        type:'get',
        url:'../../../scraping.js',
        data:[],
        dataType:'json',
        success: function(rs)
        {},
        failure : function(rs)
        {}
      });
    }
  &lt;/script&gt;
  &lt;/body&gt;
  
  &lt;/html&gt;
  
  This is the html code, and the js file is : 
  
  
  const {exec}  = require('child_process');
  const button = window.document.getElementById('buttonForScraping');
  button.addEventListener('click', function(e) {
  
  exec('scrapy crawl address', (err, stdout, stderr) =&gt; {
  
  
    console.log(`stdout: ${stdout}`);
    console.log(`stderr: ${stderr}`);
  
  });});
  </code></pre>
  <p>The scrapy command is a Python command, so I need to make an ajax call to run it on the server, I think.</p>