jQuery client-side and Java server-side - Alternatives to JSON?

1.3k views Asked by At

I have a project in Flex (client) and Java red5 that I would like to move to jquery for the client. I would like to reuse some parts of the Java server-side code, and use Java's jQuery support.

Are there other solutions that I could use for the communication with the server?

3

There are 3 answers

0
shanabus On BEST ANSWER

Yes, I've read that http://www.playframework.org is an excellent framework for building Java-based RESTful web services. This way, you can easily integrate jQuery and JSON requests with your Java web service.

This site, http://coffeebean.loicdescotte.com/2011/01/how-to-export-objects-to-json-with-play.html, has a great example of how to export content as JSON.

As for the jQuery itself, check the doc's or start with something like this:

$.ajax({
  url: "your-web-service.php",
  context: document.body,
  dataType: "json",
  success: function(data){
    // do something with data
    $(this).addClass("done");
  }
});
0
Damian On

JSON is probably your best bet, very simple and well supported in both Java and JQuery.

0
hradac On

JSON keeps things simple but you could also use XML as your data interchange format. jQuery plays well with both JSON and XML. If you were hoping to do something like SOAP I suppose it could be done but I'm pretty sure jQuery doesn't exactly do SOAP out of the box.

As far as moving to PHP goes, in your situation I wouldn't bother. If your app server is running securely, solidly, and fast enough then why even consider a change?