Ajax在Jquery中调用Rest Webservice不能在浏览器中工作,而是在Eclipse ide Browser中工作

时间:2016-03-30 04:36:21

标签: jquery ajax eclipse rest jsp

以下代码是JSP页面中对休息Web服务的调用。当我尝试在eclipse ide浏览器中加载JSP时,它会显示一条成功消息,而当我在浏览器中加载时会显示错误块(尝试即FF,chrome)。无法评估在外部浏览器中加载JSP页面时执行错误功能的主要原因。

<script type="text/javascript">
$(document).ready(function() {
    $.ajax({
        type:'GET',
        url:"http://localhost:8797/WSDemo/book?firstname=srinivas",
        dataType:"xml",
        //url:"http://services.groupkt.com/country/get/all",
        //dataType:"json",
        success:function(result){
            alert("This is success");
            alert(result);
        },
        error:function(xhr, status, error){
            alert(xhr.responseText);
        }
    });
});
</script>

0 个答案:

没有答案