First, you need to activate callbacks for the fields inside the form. The following code attaches a click event handler to a button that executes an ajax request that will serialize the entire form and then call the button back.
(html button) onClick: ((html jQuery ajax) serializeForm; callback: [ self convert ]); id: 'calclink'; with: 'Convert'.
When you use the regular form submission, Seaside will call callbacks for all fields within the form for you. When you want to initiate form submission as an ajax request, the Seaside-jQuery #serializeForm method will also serialize the contents of all input fields inside the form and call their server side callbacks in the ajax request, as in the standard presentation form. No need to change the implementation of the form!
Then you will need to disable the default behavior of the browser by clicking the submit button, which submits the form in the POST request and forces the browser to make a full-page request, which will cause Seaside to (re) display the page. There are several ways to do this, but simply changing the button type is an easy way:
(html button) bePush; ...
Finally, you need to refresh the contents of the page. Your use of #onComplete: is correct, except that this javascript code is generated the first time the page is displayed. Therefore, it displays the value of self getResult at the time the page is displayed. What you want is the value after the form submission is complete. This requires another callback:
(html button) bePush; onClick: ((html jQuery ajax) serializeForm; callback: [ self convert ]; onComplete: ((html jQuery: '#txtResult') load html: [:r | self renderTextResultContentsOn: r])); id: 'calclink'; with: 'Convert'.
UPDATE The above code makes two server calls, which you can optimize by combining callbacks into a single ajax request:
(html button) bePush; onClick: ((html jQuery ajax) serializeForm; script: [:s | self convert. s << ((s jQuery: '#txtResult') html: [:r | self renderTextResultContentsOn: r])]); id: 'calclink'; with: 'Convert'.
Or, more elegantly:
(html button) bePush; onClick: ((html jQuery id: #count) load serializeForm; html: [:r | self convert. self renderTextResultContentsOn: r]); with: 'Convert'.
The above code generates an ajax request that serializes the form (performs callbacks on the server side) and generates a script to modify the result on the page. The reason I put self convert in the script callback is Seaside-gotcha: you can only specify one response for each ajax request (for example, only one script, html, json callback per request). This is a logical limitation since a single request can only generate one response. However, you can add a few βsecondaryβ callbacks (for example, serialization form callback:json: , callback:json: etc.), but the callback specified with #callback: is also the main callback in the marine code. Therefore, I needed to put self convert in the script callback, and not in my own callback block.