views:

42

answers:

1

Hi all!!!

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"&gt;&lt;/script&gt;    
<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!!!

+3  A: 

You need to use JSONP to send AJAX request to another domain.

http://remysharp.com/2007/10/08/what-is-jsonp/

Māris Kiseļovs
thank you! i must understand how it works;)
Edward83