Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/87.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Jquery REST\u客户端\u错误_Java_Jquery - Fatal编程技术网

Java Jquery REST\u客户端\u错误

Java Jquery REST\u客户端\u错误,java,jquery,Java,Jquery,我已经通过jersey API Jar创建了REST API,它在web浏览器和测试工具fiddler上提供了所需的结果,但在restClient上通过jquery使用相同的方法,它总是移动到代码的错误部分 我的Java代码: package com.ugam.rest; import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.

我已经通过jersey API Jar创建了REST API,它在web浏览器和测试工具fiddler上提供了所需的结果,但在restClient上通过jquery使用相同的方法,它总是移动到代码的错误部分

我的Java代码:

 package com.ugam.rest;

    import javax.ws.rs.GET;
    import javax.ws.rs.Path;
    import javax.ws.rs.PathParam;
    import javax.ws.rs.core.MediaType;
    import javax.ws.rs.core.Response;
    import javax.ws.rs.Produces;
    import com.ugam.pojo.Category;

    @Path("/level")
    public class ServiceHelper {

        @GET
        @Path("getPrice/{param}")
        @Produces("application/json")
        public Response getPrice(@PathParam("param") String msg) {

            String output = msg;

            return Response.status(200).entity(output).build();

        }

        @GET
        @Path("/getCount/{param}")
        @Produces(MediaType.APPLICATION_JSON)
        public Category getCount(@PathParam("param") String msg) {

            // String output ="This response is from getCount function" + msg;
            Category category = new Category();
            category.setCategory_Name("BGNIT");
            category.setCompetitor_Name("Amazon");
            category.setCount("33822");
            category.setFinal_price("25.78");
            // Response response = Response.status(200).entity(category).build();

            return category;
        }

    }    
Jquery客户端我直接创建了用于测试的视图:

 <script type='text/javascrpt >
    $(window).load(function(){
         $.ajax(
                        {
                             dataType: 'json',
                            type:'GET',
                             url:'localhost:8080/HeatMapHelper/rest/level/getCount/Sid',

                             success: function(data)
                             {
                  document.writeln("Success in calling webService");
                             },
                             error: function(req,status,error)
                             {
                                 alert("error",req);
                     alert("Status",status);
                     document.writeln("Error while Calling REST WebService");

                             }
                        });  

                }); 
    </script>

为什么不打印实际的错误消息?我试过了,但结果是空白。我唯一能打印的是readystate和xmlhttprequest的状态-->status=0&&readystate=4您可以通过web浏览器访问该URL吗?是的,在firefox中使用browser、fiddler、restclient时,我想我在发出请求headerTry时遗漏了什么在
url
中的“localhost”之前加上“http://”。