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="https://code.jquery.com/jquery-latest.js"></script> <script> (function ($) { $(document).ready(function () { $.ajax({ // The link we are accessing. url: "http://horizon-websolutions.com", // The type of request. type: "get", // The type of data that is getting returned. dataType: "html", error: function () { alert("error"); // Load the content in to the page. $("#output").html("<p>Page Not Found!!</p>"); }, beforeSend: function () { alert("not yet"); }, complete: function () { alert("done"); }, success: function (strData) { alert("success"); // Load the content in to the page. $("#output").html(strData); } }); // Prevent default click. return(false); }); })(jQuery); </script> <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.