[英]Response statut 200 is OK but use jquery error function
I have created a restfull web service that return a json result and the URL : myURL/annonces/contract/sepcifiedContract/1 return this result: 我创建了一个restfull Web服务,该服务返回json结果,并且URL:myURL / annonces / contract / sepcifiedContract / 1返回此结果:
{"contractId":1,"labelContract":"INFO"}
and this is my script to get data: 这是我获取数据的脚本:
<script>
$(document).ready(function(){
$.ajax({
url: "http://127.0.0.1:8080/NoticeManagerServer/annonces/contract/sepcifiedContract/1",
type: "GET",
dataType: 'json',
success: render,
error: errorf,
failure: failf
});
});
function render(){
$("p").append("success function.");
}
function failf(){
$("p").append(" failure faunction.");
}
function errorf(){
$("p").append("error function.");
}
</script>
the html result is: html结果是:
error function.
what could be the problem? 可能是什么问题呢?
It might be a cross domain issue. 这可能是跨域问题。 Try:
crossDomain: true
尝试:
crossDomain: true
Write this: 这样写:
$.ajax({
url: "http://127.0.0.1:8080/NoticeManagerServer/annonces/contract/sepcifiedContract/1",
type: "GET",
dataType: 'json',
crossDomain: true,
success: render,
error: errorf,
failure: failf
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.