Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Here is how you could write the invoke() function found on this page using jQuery.

Code Block
xml
xml
titlejsp/test.jsp
 
<%@ page contentType="text/html;charset=UTF-8" language="java" %> 
<%@ taglib prefix="stripes" uri="http://stripes.sourceforge.net/stripes.tld" %> 

<html> 
<head><title>Simple jsp page</title> 
<script type="text/javascript" src='/jquery-1.2.3.min.js'></script> 
<script type="text/javascript"> 
function invoke(form, event, container) { 
    params = {}; 
    if (event != null) params = event + '&' + $(form).serialize();
    $.post(form.action, params,
        function (xml) { 
            $(container).html(xml); 
        }
    ); 
} 

$(function() { 
    $('input[type=text]').keyup(
        function() { 
            invoke($('form')[0], 'ajax', '#replaceWithAjax'); 
        }
    ); 
}
); 
</script> 
</head> 
<body> 

<stripes:form beanclass="com.example.web.actionbean.TestActionBean"> 
    <stripes:text name="text"/> 

    <div id="replaceWithAjax">The text you type will replace this text.</div> 

    <stripes:submit name="submit"/> 
</stripes:form> 

</body> 
</html> 

...