I'm new in ajax and try to get data from a post request. This is my code:
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("button").click(function(){
$.post("10.0.0.10/info/page.php",
{
id: "1234"
},
function(data,status){
alert("succesData: " + data + "
Status: " + status);
})
.fail(function(data,status) {
alert("failData: " + data + "
Status: " + status);
});
});
});
</script>
</head>
<body>
<input id="id" type="text">
<button>Change Content</button>
</body>
</html>
I just try page.php page with html form and get this json:
[{"cabin_id":"1234","city":"","type":"","year":"2009"}]
So 10.0.0.10/info/page.php working fine but my ajax code can't get data. I only get .fail alert box and it says:
What is wrong on my ajax code?
EDIT:
I see this error now:
XMLHttpRequest cannot load file:///C:/Users/KUVALYA/Desktop/post. Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https, chrome-extension-resource.