简体   繁体   中英

cant send a data from client to server

guys i am following jquery ajax tutorial .. why this code isnot working

<script type="text/javascript">
   $(document).ready(function() {
      $("#div").load( "C:\Users\workspace\AjaxProject\src\Server.java",  name="Memo",function(responseTxt, statusTxt, xhr) {
        if (statusTxt == "success")
           alert("External content loaded successfully!");
        if   (statusTxt == "error")
           alert("Error: " + xhr.status + ": " + xhr.statusText);
      });
   });
</script>

the Server.java

protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
   // TODO Auto-generated method stub
   doGet(request, response);
   System.out.print(""+request.getParameter("name"));
}

It is not possible to call any Servlet by the name of java program as shown in the example. We need to deploy and run the Servlet in it's container and then, we can call it by configured url.

Here is the complete tutorial on how to start an application with Servlet and call it using jQuery.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM