无法在PHP中使用XMLHttpRequest检索数据

script.js:

 var oReq_a = new XMLHttpRequest();
    oReq_a.open("get", "test.php", true);
    oReq_a.send();

  function test(){
    var oReq = new XMLHttpRequest();
    oReq.onload = function() {
        alert(this.responseText);
    };
    oReq.open("get", "test.php", true);
    oReq.send();

    alert("(1)"+oReq.responseText+"(2)");
    alert("(3)"+oReq_a.responseText+"(4)");
  }

test.php:

<?php
  echo "New text";
 ?>

I call it in HTML with a

<button onclick="test()" value="button"></button>

My output is, obviously, two alert boxes with

(1)(2)

and

(3)(4)

What is the problem? Thanks.

P.S. I'm running WAMP server 3.0.0, PHP version 7.0.

Edit: using network console, opened with F12, (Thanks @EduardVoid) I get this error:

script.js:3 XMLHttpRequest cannot load file:///C:/wamp64/www/project3_phplogin/test.php. Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https, chrome-extension-resource.

Edit2: I tried testing the page in Mozilla and it works, so problem is Chrome related. Any ideas?

Edit3: Tried changing the url to "./test.php". No improvement.