[HTML_AJAX-devel] Server-side method callback for formSubmit()?
Joshua Eichorn
josh at bluga.net
Tue Jul 18 09:55:30 PDT 2006
Thomas Keller wrote:
> Hey there!
>
> I'm using HTML_AJAX for a smaller bookmarks app on our site[0] already
> and currently build some kind of small widget system for a customized
> start page.
> For me a "widget" is an abstract concept of a small UI element which
> draws and updates itself within a container. This widget normally just
> displays content, but can have a config option where this output can
> be tweaked.
>
> To make a long story short, this config option/view is a simple HTML
> form which I need to get AJAXified to the server. I've looked into an
> example for HTML_AJAX.formSubmit(), but I do not believe yet that it
> fits my needs. The thing is that I do not really need to send the form
> via POST, GET is enough, but I'd like to be able to define a handler
> function which is called when the form is submitted towards
> server-side. Of course I could add "c" and "m" parameters to my form
> (to define a class and method which should be called), but then I'm
> still clueless how the actual data come to the handler. For me, it
> would be ideal to define something like
>
> class AjaxForm
> {
> function myformhandler($formvars)
> {
> }
> }
>
> where $formvars is a associative array with all the form data send
> through the formular.
>
> Is something like this already possible and, if not, could somebody
> give me a hint how this could be implemented nicely in HTML_AJAX,
> because I'd be happy to help you guys adding this feature (and send
> you a patch afterwards of course =).
>
> Greetings from Germany,
> Thomas.
>
> [0] http://mmmdi.com (hover over the red "LB" on the top right corner)
> _______________________________________________
> Html_ajax-devel mailing list
> Html_ajax-devel at lists.bluga.net
> http://lists.bluga.net/mailman/listinfo/html_ajax-devel
I would caution using GET since you can run into odd problems with
caching in IE.
But in any case you can use formSubmit to meet all your needs.
The options array lets you override any HTML_AJAX_Request option,
http://wiki.bluga.net/HTML_AJAX/HTML_AJAX_Request?
I think a setup like this would let you use formSubmit to submit to a
class method
var options = {
callback: function(result) { /* custom callback */ },
className: 'AjaxForm',
methodName: 'myformhandler',
requestUrl = 'ajaxserver.php'
}
HTML_AJAX.formSubmit('form','target',options);
You could also do
var values = HTML_AJAX.formEncode('form',true);
remove.myformhandler(values);
If one of these options works for you it would be great if you could
document it on the wiki.
http://wiki.bluga.net/HTML_AJAX/API%20Documentation
-josh
More information about the Html_ajax-devel
mailing list