Ajax调用休息Web服务无法正常工作

时间:2013-11-28 12:15:24

标签: ajax rest jquery

以下是html页面,我试图使用ajax调用其他Web服务。 我可以看到代码正在调用其余服务,但输出是错误的。

Web服务正在返回一个字符串,我已经使用mozilla rest client进行了检查。

<html>
<head>
   <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
   <title>JSP Page</title>
   <script src="D:\bstrap\js\jquery.json-2.2.js"></script>
   <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js">
   </script>
   <script type="text/javascript">
       function callme(){
            alert("hello");
            var data ='{  "title": "Enter Sandman",  "singer": "Metallica"}'
    $.ajax({
         type: "GET",
         url: "http://www.mywebservice.exm/RestTodo/rest/todoform",
         contentType: "text/plain",
         success: function(resp){alert("Server says" + resp);},
         error: fu`enter code here`nction(e){ alert("An error has occured");},

     });
   }
  </script> 
</head>

<body>
    <form id="form1" method="POST">
        <input type="button" Value="SUBMIT" onclick="callme();">
    </form>
</body>

   > service method**

**

      @GET
  @Produces("text/plain")
  public String sayHello() throws Exception {

        return "done";
      }

get只是生成一个文本,但即便无法接收。它始终是 移动到错误块

0 个答案:

没有答案
相关问题