【发布时间】:2014-03-12 06:48:41
【问题描述】:
我尝试通过在 jsp 文件中使用 jquery 来编写 ajax get。但它总是给出错误信息。我在我的方法中找不到错误。
这是我的 ajax 函数。请帮帮我。
<script type="text/javascript">
$.ajax({
url: "http://crowderia.cloudapp.net/ichainwsDev/api/rest/json/product.list",
type: "GET",
data: '{"partyid":4}',
contentType: 'application/json; charset=UTF-8',
dataType: 'json',
success: function(msg){
alert("success : "+data);
},
error:function(msg){
alert("failure");
}
});
</script>
错误是: XML HttpRequest 无法加载 http://crowderia.cloudapp.net/ichainwsDev/api/rest/json/product.list。 请求的资源上不存在“Access-Control-Allow-Orgin”标头。因此不允许访问 Orgin 'http://localhost:4040'
【问题讨论】:
-
contentType: 'application/json; charset=UTF-8'对于 GET 请求完全没有意义。没有指定内容类型的请求体!
标签: javascript jquery ajax jsp