Forum: Ruby on Rails doing synchronous JSON on rails

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Devon Jones (Guest)
on 2006-04-17 23:31
(Received via mailing list)
So I have found how to generate json in a rails app in the wiki
(http://wiki.rubyonrails.com/rails/pages/HowtoGenerateJSON), what I have
yet to figure out is how to make a synchronous call via json to rails so
that I can block while fetching the information from a user request.

context:
I have used JSON on top of java in the past, and in order to make
synchronous calls I had to do the following:
1) include json.js

	<script type="text/javascript" src="jsonrpc.js">
	<script type="text/javascript" src="myapp.js">

2) add the json object to the page:

	<jsp:useBean id="JSONRPCBridge" scope="session
class="com.metaparadigm.jsonrpc.JSONRPCBridge" />

3) in the jsp, register a json object as an object that can be called
from the javascript of the page

	<% JSONRPCBridge.registerObject("myTestObject", aTestObject); %>

4) Register the JSON Servlet
5)  Then call the function either async:

	jsonrpc.myTestObject.myFunction(myCallBack, "hello");

or sync:

        var result = jsonrpc.myTestObject.myFunction("hello");
        alert(result);


I would like to know how I would go about getting to #5 in rails and
http://wiki.rubyonrails.com/rails/pages/HowtoGenerateJSON really only
explains the actual writing out of the JSON object.

Thanks,
Devon Jones
This topic is locked and can not be replied to.