jQueryAjax中的调用post给出错误
我试图使用POST方法从jQueryAjax调用rest服务。下面是我的代码:jQueryAjax中的调用post给出错误,jquery,ajax,Jquery,Ajax,我试图使用POST方法从jQueryAjax调用rest服务。下面是我的代码: <!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 Chang
<!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>
它不会在firefox浏览器控制台中返回任何响应。我在谷歌chrome上试过,在网络标签下,它显示了一些错误,我不明白。请帮助我。您不能使用javascript执行跨源ajax POST请求。看看这个帖子