sto usando qui sotto comando curl per ottenere i dati dal gruppo Druid ospitato su server remoto, in formato JSONJavascript equivalente per il comando ricciolo
curl -X POST "http://www.myserverIP.com:8080/druid/v2/" -H 'content-type: application/json' -d '{"queryType": "groupBy","dataSource": "twsample","granularity": "none","dimensions": ["created_at"],"aggregations": [{"type": "count", "name": "tweetcount"}],"intervals": ["2013-08-06T11:30:00.000Z/2020-08-07T11:40:00.000Z"]}'
ma non sono in grado di creare un equivalente javascript metodo che farà la stessa cosa, sto usando sotto il codice per farlo.
function sendCurlRequest(){
var json_data = {
"queryType": "groupBy",
"dataSource": "twsample",
"granularity": "none",
"dimensions": ["created_at"],
"aggregations": [
{"type": "count", "name": "tweetcount"}
],
"intervals": ["2013-08-06T11:30:00.000Z/2020-08-07T11:40:00.000Z"]
};
$.ajax({
cache : false,
type: 'POST',
crossDomain:true,
url: 'http://www.myserverIP:8080/druid/v2/',
data:json_data,
//dataType: "jsonp",
contentType:"application/jsonp",
success: function(data){
alert(data);
var pubResults = data;
},
error: function(data){
alert("ERROR RESPONSE FROM DRUID SERVER : "+JSON.stringify(data));
},
complete: function(data){
console.log("call completed");
}
});
}
Qualsiasi aiuto sarà apprezzato.
qual è il messaggio di errore? c'è qualche? Sospetto un problema con CORS/cross-origine ... – thriqon
anche, contentType dovrebbe essere 'application/json' nella parte JS – thriqon