title: Some problems related to url, Javascript and Json
body: <p>I would need a little hand as I cannot get this code to work ... via the input tag in html, I should take the url entered by the user, save it in the variable pageURL, transform everything to JSON and send to my nodejs server the whole. However, when I try to do this the request is not even sent and I don't know why. If instead I try to put a simple string instead of the url in the input box, everything works perfectly ... any ideas? Thank you!!</p>
  <p>HTML</p>
  <pre><code>&lt;main&gt;
          &lt;div id=&quot;main-scanner&quot;&gt;
              &lt;div id=&quot;inner-scanner&quot;&gt;
                  &lt;h1 id=&quot;scanner-h1&quot;&gt;Ready to scan your page!&lt;/h1&gt;
                  &lt;form id=&quot;scanner-form&quot;&gt;
                      &lt;label id=&quot;scanner-label&quot;&gt;Please, enter the URL you want to scan:&lt;/label&gt;
                      &lt;br&gt;
                      &lt;input type=&quot;url&quot; id=&quot;scanner-input&quot; placeholder=&quot;              Scan me!&quot; required&gt;
                      &lt;br&gt;
                      &lt;button id=&quot;scanner-button&quot;&gt;Scan&lt;/button&gt;
                  &lt;/form&gt;
              &lt;/div&gt;
              &lt;div id=&quot;result&quot;&gt;
              &lt;/div&gt;
          &lt;/div&gt;
          &lt;script src=&quot;../js/index.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
      &lt;/main&gt;
  </code></pre>
  <p>app.post from the server, just a test to see if it receives the request</p>
  <pre><code>app.post(&quot;/send&quot;, async (req, res) =&gt; {
      console.log(&quot;test&quot;)
      let requestData = req.body;
      console.log(requestData)
  </code></pre>
  <p>JavaScript code</p>
  <pre><code>
  document.getElementById(&quot;scanner-button&quot;).addEventListener(&quot;click&quot;, send);
  
  function send(){
      var pageURL =document.getElementById('scanner-input').value;
      console.log(pageURL)
      let infos = {
          url : pageURL,
          vulnerable : false,
          report : &quot;&quot;
      };
  
      let request = new XMLHttpRequest();
      request.open(&quot;POST&quot;, &quot;http://localhost:3000/send&quot;, true);
      request.setRequestHeader('Content-Type', 'application/json');
      console.log(infos)
      let data = JSON.stringify(infos);
      request.send(data)
  }
  
  </code></pre>