How to execute an Ajax request on CouchDB (http: // <username> .couchone.com /)

I am trying to create a simple AJAX request (via jQuery) at http: // yourusername .couchone.com / (almost the same as if I installed couchdb on localhost)

If I go to http://**yourusername**.couchone.com/through the browser, I get: {"couchdb":"Welcome","version":"1.0.1"}So, this looks like serialized JSON.

So, I wrote the JS code:

$(function() {
        $.getJSON('http://www.********.couchone.com/', function(data) {
                console.log(data.couchdb);
                console.log(data.version);

            });
    });

But the code does not work. The FireBug console shows that the GET request has no response (the entire line is in red). All I see is the request header and response header, but NO DATA (as an answer)

Request Header:

Host :  www.*******.couchone.com
User-Agent :    Mozilla/5.0 (Windows; U; Windows NT 6.1; de; rv:1.9.2.10) Gecko/20100914 Firefox/3.6.10 FirePHP/0.4
Accept :    application/json, text/javascript, */*
Accept-Language :   de-de,de;q=0.8,en-us;q=0.5,en;q=0.3
Accept-Encoding :   gzip,deflate
Accept-Charset :    ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive :    115
Connection :    keep-alive
Origin :    null

Answer Header:

Server :    CouchDB/1.0.1 (Erlang OTP/R13B)
Date :  Sun, 26 Sep 2010 12:45:47 GMT
Content-Type :  application/json
Content-Length :  40
Cache-Control :  must-revalidate

Ideas? Suggestions?

PS sorry for bad english

+4
2

JSON- .

JSONP. <script> XMLHTTPRequest. <script> ​​ .

, couchdb JSONP. JSONP :

http://someUrl/somePath?jsonp=mycallback

jsonp javascript contenxt:

myCallback({ JSON:data, JSON:data });

, JSONP, javascript . , , , couchdb.

, $.getJSON() , URL- , .

P.S. couchone.com, , , JSONP. script, ( URL- couchdb), , JSONP.

+5

, MightyE , postscript - CouchOne JSONP. http://YOURSITE.couchone.com/_utils/config.html allow_jsonp httpd true.

$.ajax({
   url: 'http://yoursite.couchone.com/',
   type: 'get',
   dataType: 'jsonp',
   success: function(data) {
      alert(data.couchdb);
      alert(data.version);
   }
});

.

+10

All Articles