title: Ajax POST, check PHP $_GET and then $_POST
body: <p>Using the following Ajax POST function on form submit (simplified here):</p>
  <pre><code>    $form.on(&quot;submit&quot;, function (i) {
            i.preventDefault();
            var sendEmail = 1;
            ValidateForm(sendEmail, &quot;goSignup&quot;);
          });
      
          function ValidateForm(sendEmail, action) {
                  $.ajax({
                      type: &quot;POST&quot;,
                      url: window.location.pathname,
                      dataType: &quot;json&quot;,
                      data: {
                          ajaxRequest: 1,
                          sendEmail: sendEmail,
                      }
  }
  </code></pre>
  <p>After I post this I want to use a conditional GET parameter that equals 1 (i.e <a href="https://www.example.com?test-parameter=1" rel="nofollow noreferrer">https://www.example.com?test-parameter=1</a>) and then if it's present in the URL use one or another function from there if the ajaxRequest is received from $_POST in my PHP:</p>
  <pre><code>public function __construct() {
      $testingParameter = $_GET[&quot;test-parameter&quot;] ?? '';
      if (trim($testingParameter) == '1') { // if has get parameter equal 
         if (!empty($_POST['ajaxRequest'])) { // if JS postRequest has been posted
                  $this-&gt;handlePostRequests();
          }
          echo 'has get parameter';
      } else { // else use old logic
          if (!empty($_POST['ajaxRequest'])) {
              $this-&gt;handleOtherRequests();
          }
          echo 'no get parameter';
      }
  }
  </code></pre>
  <p><strong>Issue:</strong>
  I get the correct echo from PHP but when I submit the form with Ajax its still using the <code>handleOtherRequests();</code> instead of the <code>handlePostRequests();</code> function if I'm using the url <a href="http://www.example.com?test-parameter=1" rel="nofollow noreferrer">www.example.com?test-parameter=1</a>.</p>
  <p>Likely getting some basic PHP logic wrong here, would appreciate if anyone could guide me in the right direction with this.</p>