Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting an empty response when calling CouchDB over ajax

I'm new to CouchDB, so please bear with me.

I have an instance of CouchDB running on a VM. I can access it just fine through the browser via futon or directly at:

http://192.168.62.128:5984/articles/hot_dog

Calling that URL in a browser returns the proper JSON. But, when I try to call that exact same URL via ajax, I get nothing:

var ajaxUrl = 'http://192.168.62.128:5984/articles/hot_dog';
$.getJSON(ajaxUrl, null, function(data) { alert(data); });

Looking at the response header with Firebug shows me that the HTTP response was 200 and the content-length is the right size. Even the Etag matches with what is in CouchDB. But the response itself is empty!

The URL is absolutely right; I've triple checked, and copy/pasted it directly (and besides it wouldn't give a 200 response if it weren't). I'm using jQuery 1.4.2, and CouchDB 0.8

What's going on?

like image 469
swilliams Avatar asked Dec 29 '22 22:12

swilliams


1 Answers

Try appending callback=? to the url like this. This will trigger jQuery to issue a jsonp request.

var ajaxUrl = 'http://192.168.62.128:5984/articles/hot_dog?callback=?';

If this doesn't fix it additionally you should append a sample output of the json this url gives in the browser.

like image 56
jitter Avatar answered Jan 18 '23 03:01

jitter