I am trying to call rest service from JQuery ajax using POST method. Below is my code :
<!DOCTYPE html>
<html>
<head>
<script src="lib/js/jquery/jquery-1.7.2.min.js"></script>
</head>
<body>
<div id="div1">
<h2>Let jQuery AJAX Change This Text</h2>
</div>
<button id="totalRevenue">Get External Content</button>
<script>
function jsonpCallback(response) {
console.log("response from server: "+JSON.stringify(response));
};
$(document).ready(function() {
$("#totalRevenue").click(function() {
console.log('inside function');
var input = {
"facets": {
"stats": {
"statistical": {
"field": "@fields.TransTotalAmount"
},
"facet_filter": {
"fquery": {
"query": {
"filtered": {
"query": {
"bool": {
"should": [
{
"query_string": {
"query": "*"
}
}
]
}
},
"filter": {
"bool": {
"must": [
{
"range": {
"@timestamp": {
"from": 1411136110765 ,
"to": "now"
}
}
}
]
}
}
}
}
}
}
},
"stats_All Transactions": {
"statistical": {
"field": "@fields.TransTotalAmount"
},
"facet_filter": {
"fquery": {
"query": {
"filtered": {
"query": {
"bool": {
"should": [
{
"query_string": {
"query": "*"
}
}
]
}
},
"filter": {
"bool": {
"must": [
{
"range": {
"@timestamp": {
"from": 1411136110765 ,
"to": "now"
}
}
}
]
}
}
}
}
}
}
}
},
"size": 0
};
$.ajax( {
type:"POST",
url:"http://esu2v977:9200/labs-uat-2014-09-19/_search",
dataType:"jsonp",
contentType:"application/javascript; charset=UTF-8",
data:JSON.stringify(input),
successs:jsonpCallback,
error: function(data) {
console.log("there is some problem to get the response :"
+JSON.stringify(data));
}
});
});
});
</script>
</body>
</html>
It is not returning any response in firefox browser console. I have tried in google chrome, under network tab it is showing some error, I am not getting it. Please help me.