嗨,我開發了一個基於球衣1.8寧靜的Web服務。 當我從瀏覽器中調用webservice的類似 http://localhost:8080/EC/EC/loginValidate/epicSearch/IVE0016808
我有輸出像無法從jquery調用jersey webservice?
{"name":"Aneel Kumar Ravula","pollingStationLocation":"MARRIPALLI MPP SCHOOL","gender":"male","age":23,}
但是,當我從失敗的jQuery Ajax和控制研究,在調用誤差函數。
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
<script>
$(document).ready(function() {
// fetch some more records from the server side
$.ajax({
type: "GET",
contentType: "json",
url: "http://localhost:8080/EC/EC/loginValidate/epicSearch/IVE0016808",
success: function(){alert('sucess by anil')},
error: function(event){alert('fail by anilevent '+event)}
});
});
</script>
</HEAD>
<BODY>
</BODY>
</HTML>
現在這是我最新的代碼如何獲得響應
$(document).ready(function() {
jQuery.support.cors = true;
// fetch some more records from the server side
$.ajax({
type: "GET",
dataType : "JSON",
url: "http://localhost:8080/EC/EC/loginValidate/epicSearch/IVE0016808",
crossDomain : true ,
success: function(resp){alert('sucess by anil'+resp)},
error: function(jqXHR, testStatus, errorThrown){alert('fail by anilevent '+errorThrown)}
});
});
你真的需要跨域:真正的本地主機? – Dodecapus
實際上不是neede,但我嘗試了不同的選項忘記刪除 – AnilHoney
取出contentType或將其更改爲dataType – Dodecapus