| Safe Haskell | None | 
|---|
MFlow.Forms.Ajax
Description
A very simple (but effective) support for AJAX. The value of a javaScript variable is sent to the server. The server must return a valid sequence of javaScript statements that are evaluated in the client.
This example increase the value, from 0 on, in a text box trough AJAX:
import Text.XHtml import MFlow.Forms import MFlow.Forms.Ajax ajaxsample= do ajaxheader html= thehtml <<ajaxHead<< html setHeader ajaxheader ajaxc <-ajaxCommand"document.getElementById('text1').value" (n -> return $ "document.getElementById('text1').value='"++show(read n +1)++"'") ask $ (getInt (Just 0) <! [("id","text1"),("onclick",ajaxc)]) breturn()
- ajaxCommand :: (MonadIO m, MonadState (MFlowState view) m) => String -> (String -> IO String) -> m String
 - ajaxHead :: Html -> Html
 
Documentation
Arguments
| :: (MonadIO m, MonadState (MFlowState view) m) | |
| => String | The javScript variable whose value will be sent to the server  | 
| -> (String -> IO String) | The server procedure to be executed with the variable value as parameter. It must return a string with valid javaScript code to be executed in the client  | 
| -> m String | return the javascript of the event handler, to be inserted in the HTML to be sent to the client  | 
Install the server code and return the client code for an AJAX interaction.