Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var information = {
- "name": name,
- "mobile": mobile,
- "email": email
- }
- $.ajax({
- type: 'POST',
- url: 'http://xxx:8080/PostEx/test/testservice',
- jsonpCallback: 'jsonCallback',
- cache: true,
- data: information,
- dataType: 'jsonp',
- jsonp: false,
- success: function (response) {
- alert(response);
- },
- error: function (e) {
- $("#divResult").html("WebSerivce unreachable");
- }
- });
- package com.services;
- import javax.ws.rs.Consumes;
- import javax.ws.rs.POST;
- import javax.ws.rs.Path;
- import javax.ws.rs.Produces;
- import javax.ws.rs.QueryParam;
- @Path("/testservice")
- public class TestService {
- @POST
- @Consumes("application/json")
- @Produces("application/json")
- public String getData(@QueryParam("toppingid") String toppingid) {
- System.out.println("The toppingid is" + toppingid);
- String toppingobj = "SomeData";
- String response = "jsonCallback(["+toppingobj.toString()+"])";
- return response;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement