You probably get nothing because either your MongoDB instance does not support JSONP (and you need it because normally you can't do cross-domain ajax requests) or your query is incorrect (apparently you have to use ?jsonp=
instead of ?callback=
).
One way would be to use JSONP directly. Since you are using jQuery you could try something like that:
$.ajax({
url: 'http://72.123.xxx.xxx:27080/weather/_cmd',
dataType: 'jsonp',
jsonp: 'jsonp', // <-- the name used in '?jsonp=' part of url
data: {
cmd: {
"geoNear" : "items",
"near": [6.8590845,79.9800719]
}
},
success: function(res) {
console.log(res);
}
});
According to this StackOverflow answer:
Does MongoDB have a native REST interface?
it should work if you fire MongoDB instance with --jsonp
option (in order to enable support of JSONP). I haven't tried it though.
Also there might be other issues. For example the database may simply drop the connection, you might not have privileges, etc. Generally it is never a good idea to connect from client to database directly. You should use a web server as a man in the middle.