残りのサービスから簡単なテキストを送信し、ajax 呼び出しを使用して読み取ろうとしています。jsonp とクロスブラウザの互換性に関する多くの回答が見つかり、クロスドメインも試しました。
残りのサービスは次のとおりです。単純な文字列のみを送信するようにすべてを切り詰めました。
@GET
@Path("/getcontents2")
@Produces({MediaType.TEXT_PLAIN})
public String getContents2(@QueryParam("name") String msg) {
return "abc";
}
ajax 呼び出し:
$(document).ready(function() {
$.ajax({
type: 'GET',
url: 'http://metrics/getcontents2?name=Work/loc.txt',
crossDomain: true,
async: false,
dataType:'html',
success: function (data) {
console.log(data);
},
error: function (xhr, ajaxOptions, thrownError) {
console.log(xhr.status);
console.log(thrownError);
console.log(xhr.responseText);
console.log(xhr);
},
});
});
ブラウザは文字列をそのまま開きます。jquery スクリプトで何かが本当に間違っていると思います。
Firebug のエラー:
GET http://metrics/getcontents2?name=Work/loc.txt 200 OK 4ms
0
(an empty string)
(an empty string)
Object { readyState=0, status=0, statusText="error"}