CORS localhost ajax request

I have an HTML page (http://localhost:8888/test/test.html) in which I’m trying to pull data from a Drupal 7 website.

I’m using this AJAX code with HTML-Request. I have tried JSON and the website prevents me from pulling, even I have added the following code to pull the data.

<?php header('Access-Control-Allow-Origin: *'); ?>

This is the HTML page that requests AJAX from Drupal 7 website. Could you please check it for me?

<script src=""></script>
  (function ($) {
    $(document).ready(function () {
        // The link we are accessing.
        url: "",
        // The type of request.
        type: "get",
        // The type of data that is getting returned.
        dataType: "html",
        error: function () {
          // Load the content in to the page.
          $("#output").html("<p>Page Not Found!!</p>");
        beforeSend: function () {
          alert("not yet");
        complete: function () {
        success: function (strData) {
          // Load the content in to the page.
      // Prevent default click.
<div id="output"></div>

Please help me telling the website to accept my localhost request to pull data from the server. I have tested the same code on a pure PHP page and it is working fine.

Go to Source of this post
Author Of this post: Mohammad Moussa
Title Of post: CORS localhost ajax request
Author Link: {authorlink}