Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2014
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. var information = {
  2. "name": name,
  3. "mobile": mobile,
  4. "email": email
  5. }
  6.  
  7. $.ajax({
  8. type: 'POST',
  9. url: 'http://xxx:8080/PostEx/test/testservice',
  10. jsonpCallback: 'jsonCallback',
  11. cache: true,
  12. data: information,
  13. dataType: 'jsonp',
  14. jsonp: false,
  15. success: function (response) {
  16.  
  17. alert(response);
  18. },
  19. error: function (e) {
  20. $("#divResult").html("WebSerivce unreachable");
  21. }
  22. });
  23.  
  24. package com.services;
  25. import javax.ws.rs.Consumes;
  26. import javax.ws.rs.POST;
  27. import javax.ws.rs.Path;
  28. import javax.ws.rs.Produces;
  29. import javax.ws.rs.QueryParam;
  30. @Path("/testservice")
  31. public class TestService {
  32. @POST
  33. @Consumes("application/json")
  34. @Produces("application/json")
  35. public String getData(@QueryParam("toppingid") String toppingid) {
  36. System.out.println("The toppingid is" + toppingid);
  37. String toppingobj = "SomeData";
  38. String response = "jsonCallback(["+toppingobj.toString()+"])";
  39. return response;
  40. }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement