Reputation: 6686
I try to get data from server http://someserver12345.com If i download it for example with C# DownloadString or open it in browser it returns body with data and from FireBug's log Content-Length is equal to data's size. So all results are ok; For example response data can be json documents and by opening in browser each time server returns json document;
But when i try to get data with jQuery GET request then Content-Length is still correct, but data is empty!!!
This is my code:
<script src="http://code.jquery.com/jquery-latest.min.js"></script>
<script>
$(document).ready(function() {
$.ajaxSetup({
beforeSend: function(request) {
request.setRequestHeader('Accept', 'application/json');
}
});
$.ajax({
type: 'GET',
url: 'http://someserver12345.com',
success: callback
});
function callback(data, status) {
alert(data);
//$('div').text(data);
}
});
</script>
I found that data is not null object in callback function;
I am new in this, help me please;) Any ideas and advices will be cool!;)
Thank you!!!
Upvotes: 2
Views: 2943
Reputation: 17275
You need to use JSONP to send AJAX request to another domain.
http://remysharp.com/2007/10/08/what-is-jsonp/
Upvotes: 5