0

phonegap を使用して、サーバーから json データを取得しようとしています。ただし、常に onCreateReportError メソッドを実行し、status=0 を与えています。私は他のスタックオーバーフローの関連する質問を調べましたが、私のコードには何も問題がないようです。問題は何ですか?

$('#randomPerson').click(function(){
    $.ajax({
          type : "POST",
          url : 'http://localhost:9090/mvc-1.0.0-BUILD-SNAPSHOT/api/person/random',
            crossDomain: true,
            beforeSend : function() {$.mobile.loading('show')},
            complete   : function() {$.mobile.loading('hide')},
            dataType   : 'json',
          data : {},
          success: onCreateReportSuccess,
         error : onCreateReportError
        });


    function onCreateReportSuccess(person, textStatus, jqXHR) {
        console.log('Status: ' + textStatus);
        $('#personResponse').text(person.name + ', age ' + person.age);
    }

    function onCreateReportError(jqXHR, textStatus, errorThrown) {
        console.log('Status: ' + textStatus);
        console.log('Error: ' + errorThrown);
        alert('Error creating report');
    }
});
4

1 に答える 1