I am a novice to PHP, trying to learn.
I have my php file present in www folder in the WAMP server.
<?php
echo 'Hi';
?>
This can be run if I go http://127.0.0.1/testRequestParameter.php
from my Browser, it prints Hi
So now I created an HTML page(not present in the same directory)
<html>
<head>
<script src="jsLibrary/jquery-1.11.1.min.js" ></script>
</head>
<body>
<script type="text/javascript">
function getTestDataFromAjax()
{
var url = 'http://127.0.0.1/testRequestParameter.php';
$.ajax({
url: url,
success: function(data) {
alert(data);
},
async:false
});
}
</script>
<input type="submit" name="Button" onclick="javascript:getTestDataFromAjax(); return false;" />
</body>
</html>
And when I try to call that php through AJAX, the response is blank.
May be it I am missing something, any help will be appreciated.
Finding1: In my firebug it is showing, Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://127.0.0.1/testRequestParameter.php. This can be fixed by moving the resource to the same domain or enabling CORS.
Any setting which I need to change?