I am puzzled as to why PHP sees my request string as undefined.
$_GET['ask']in my php file produces this error -> Notice: Undefined index: ask.
But when I query the php file from the url bar in the browser like this
localhost/Websites/webProject/data.php?ask=myquery
I have set the php file to echo my string and it does do exactly that but only when I query it from the browser URL bar.
But when running the AJAX code normally from the parent html/php file
 request.open("GET", "data.php?ask=myquery", true); 
The PHP file does not see the query string and thinks its undefined.
Why is this the case?
I have tried to use
$_REQUEST[];but to no avail.
I am using pure javascript for the AJAX requests.
Here is the javascript
requestResponse();
function requestResponse()
{
  var READY_STATE_DONE = 4; /* request finished and response is ready */
  var SUCCESS          = 200; /* "OK" */
  setInterval(function(){
    var request = new XMLHttpRequest();
    request.onreadystatechange = function(){
      if(this.readyState == READY_STATE_DONE && this.status == SUCCESS)
      {
        var response = this.responseText;
        console.log(request.responseText);
        document.getElementById("test").innerHTML += "<br>" + response;
      }
    }
    request.open("GET", "data.php?ask=myquery", true);
    request.send();
  }, 3000)
}
Here is the PHP content
testRequest();
function testRequest()
{
  $reqString = $_REQUEST['ask'];
  include("dbCredentials.php");
  include("dbConnect.php");
  if($reqString == "myquery")
  {
    echo("<br />REQUEST IS: " . $reqString);
    echo("<br /> Your request is granted");
  }
}
DISCLOSURE: I have replaced the previous php file with data.php.
 
    