title: Request to api using jquery ajax with php
body: <p>hi guys i'm getting stuck in my code i'm requesting to a php api to get data with using jquery ajax. please help me with a solution</p>
  
  <p><strong>Ajax code</strong></p>
  
  <pre><code>     $.ajax({
        url: request_url+"courses.php",
        type: 'POST',
        dataType: 'jsonp',
        cors: true ,
        contentType:'application/json',
        data: { request_courses: courses },
        secure: true,
        headers: {
          'Access-Control-Allow-Origin': '*',
        },
        beforeSend: function (xhr) {
          xhr.setRequestHeader ("Authorization", "Basic " + btoa(""));
        },
        success: function (data){
          console.log("helo "+data);
        }
     });
  </code></pre>
  
  <p><strong>Php Api code</strong></p>
  
  <pre><code>   if(isset($_POST['request_courses'])){
          $courses = mysqli_query($conn, "SELECT * FROM `courses`");
          while ($rows = mysqli_fetch_assoc($courses)) {
              $data[] = $rows;
          }
          echo json_encode(array('status' =&gt; 1,'message'=&gt;'responce_courses','data'=&gt;$data));
      }
  </code></pre>
  
  <p><strong>Error</strong> While runing this code</p>
  
  <pre><code>courses.html:1 A cookie associated with a cross-site resource at http://localhost/ was set 
  without the `SameSite` attribute. A future release of Chrome will only deliver cookies with 
  cross-site requests if they are set with `SameSite=None` and `Secure`. You can review 
  cookies in developer tools under Application&gt;Storage&gt;Cookies and see more details at 
  https://www.chromestatus.com/feature/5088147346030592 and 
  https://www.chromestatus.com/feature/5633521622188032.
  
  
  
  Access to XMLHttpRequest at 'file:///home/punkaj/Music/Cordova/ithub/www/index.html' from 
  origin 'null' has been blocked by CORS policy: Cross origin requests are only supported for 
  protocol schemes: http, data, chrome, chrome-extension, https.
  jquery.js:2 GET file:///home/punkaj/Music/Cordova/ithub/www/index.html net::ERR_FAILED
  send @ jquery.js:2
  ajax @ jquery.js:2
  h @ plugins.js:45
  i @ plugins.js:45
  dispatch @ jquery.js:2
  y.handle @ jquery.js:2
  </code></pre>