Execute curl command using jquery-ajax

curl, jquery, json, jsonp

Solution

Finally I Come up with the Solution.

$.ajax({
    url: '/weather/_cmd',
    type:'POST',
    dataType: 'json',
    crossDomain : true,
    data: {
        cmd: JSON.stringify({
            "geoNear" : "items",
            "near": [6.8590845,79.9800719]
        })
    },
    success: function(res) {
        //do stuff with res
    }
});

ProxyPass /weather http://72.123.xxx.xxx:27080/weather/_cmd
ProxyPassReverse /weather http://72.123.xxx.xxx:27080/weather/_cmd

Add above Proxy pass to your Apache and try this. it will work. problem is you cant pass POST Request by using jsonp. mongo we need POST requests. this is one way to do it. :D i tested it and works perfectly for me. it will not accept json and you have to pass it as string.

Problem

I executed curl command using following input to the mongoDB. ``` curl --data 'cmd={"geoNear" : "items", "near":[6.8590845,79.9800719]}' 'http://72.123.xxx.xxx:27080/weather/_cmd' ``` I want to execute that using jsonp or json and get the response. I Tried below jsonp request. ``` var url = "http://72.123.xxx.xxx:27080/weather/_cmd"; $.getJSON(url + "?callback=?", { cmd:{"geoNear" : "items", "near": 6.8590845,79.9800719]} }, function(tweets) { } ); ``` I got Nothing from Console. Please help me with this. thanks.

Original source

Related problems