0

I am new in web service development. Currently I am developing an application (in html5 using javascript and jquery) in which I wanted to send data to web service in Json format.

My question are: 1) How to send(post) data to web service using javascript ? 2) How to retrieve json data at server side ? 3) How to get data from the web service in json format ? 4) How to retrieve json data at client side ?

1
  • Have you not looked at any tutorials on Ajax? Commented Mar 11, 2014 at 12:49

3 Answers 3

0

Cast you json to string than send to server. In the server side cast it json again.

Sign up to request clarification or add additional context in comments.

4 Comments

can you please give me an exmple or its link ?
@Raaga can you use php?
no php only java at web service side and html5, javascript, jquery at client side.
@Raaga If I don't misunderstand you use java servlet. Then this link will help you: stackoverflow.com/questions/19424313/…
0

JSON is just a way to encapsulate data. You should have parses on both sides that parse the json into data you can work with. On your Java serve you can use e.g. https://code.google.com/p/json-simple/

Comments

0
  1. Easiest would be to use jquery ajax() function.

    $.ajax({ type: 'post', dataType: 'json', data: { "var1": value1, "var2": value2 }, url: 'www.example.com' }) .success( function() { console.log( 'success' ); });

  2. This depends on what backend do you use on server, I can reccomend node.js with express.

  3. The same as p1, the only difference that you will have to parse data you have received in success() function.

  4. I am not sure if I understand correctly what you mean.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.