I'm trying to pull down some list data from listdata.svc using the standard method as documented in the msdn:

var listUrl = 'http://development.contoso.com/_vti_bin/ListData.svc/Contacts';
                'type': 'GET',
                'url': listUrl,
                'dataType': 'json',
                'success': function(data){ alert("hello json!") }

But I am not having any luck.

I am running the ajax query from a different subdomain (dev1.contoso.com to devb.contoso.com), but both machines live under the same root domain ("contoso", for arguments sake) So is the issue the sub-domain?

Since listdata.svc doesn't do JSONP, what are my options?

I have confirmed that the ListData.svc does return data normally from the browser.


To fall inside the same-domain restrictions of JavaScript you must have the same fully-qualified domain, including schema and port. I'm assuming your 'different physical machine' has a different hostname, so it is not same-domain.

If you want to query across domains you will need to look at cross-domain ajax (e.g. CORS or similar).

For completedness, this is what I use (works only in same domain). Note that the converter requires a recent version of jQuery.

readItems = function (itemList, successFunc, expands) {
    var requestUrl = webServiceUrl + itemList + (expands || '');

        type: "GET",
        contentType: "application/json; charset=utf-8",
        url: requestUrl,
        processData: false,
        async: true,
        dataType: "json",
        converters: {
            // WCF Data Service .NET 3.5 incorrectly escapes singles quotes, which is clearly
            // not required (and incorrect) in JSON specs.
            // http://bugs.jquery.com/ticket/8320?cversion=0&cnum_hist=1
            "text json": function (textValue) {
                return jQuery.parseJSON(textValue.replace(/(^|[^\\])\\'/g, "$1'"));
        success: function (data, status, xhr) {
        error: function (xhr, status, error) {
            // Some error handling;
  • IE 8 Support for CORS is limited to text/plain for requests - would this be an issue? – Ray May 14 '13 at 16:01

Couple of points here to mention:

first check whether you are correctly referring js files.next you can put debugger to see what data you are receiving or F12 debugger tool can be used to see what data list svc returning. pls check below example

http://navoneel23.blogspot.in/2013/02/calling-rest-with-jquery-from.html Calling Rest service with jquery

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.