I am firing a GET request using jquery but not getting response what could be problem ?
Below is the html code. I am getting an alert showing
Please anyone provide me some running example, in which should be using some well known website which i can also access like http://www.google.co.in or http://www.jlcindia.com
error:error
<html>
<script type="text/javascript" src="jquery-1.8.1.min.js"></script>
<Script Language="JavaScript">
function getFullName(){
//alert('fun call');
$.ajax({
type: "GET",
url: "http://www.jlcindia.com",
dataType: "html",
success: function(data) {
alert('success'+data);
},
error: function(xhr, textStatus, errorThrown) {
if (textStatus !== null) {
alert("error: " + textStatus);
} else if (errorThrown !== null) {
alert("exception: " + errorThrown.message);
}
else {
alert ("Don't know what is error");
}
}
});
}
</Script>
<body>
<input type="button" value="Show Full Name" onClick="getFullName()">
</body>
</html>
You are making an ajax request to a different domain. And that won’t work due to the same origin policy
Example:
your site is hosted on http://www.mydomain.com and you are trying to access http://www.otherdomain.com through ajax. This is not possible.
Ajax requests work only on the same domain as the hosted script.