Using Ajax in Model Glue

We can use prototype/ JavaScript frame works to implement Ajax functionality in Model Glue applications. Model Glue architecture is mainly event driven and while calling an Ajax request we need to call an event that processes the Ajax request. The Ajax call can be made in the prototype framework by using the Ajax.Request method.




In the Ajax.Request, call the event that processes your ajax function. Return the data from your ajax call in html format and fill it in your form. The responseText contains the html content that shows after calling the Ajax request. We have used the scriptaculous code to update our page after the ajax call was completed along with a slide effect. In the above example element1 is the name of our html container that holds our result after the ajax call.  A javascript function is used to call the ajax request on the click of a button(see below). Here div_filldata is the container that gets filled with html content after finishing the ajax call.


Also be sure to include the javascript files in your page (see below) before you roll out your application!!


Click here to see this example in action!!


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: