James Gardner: Home > Blog > 2007 > YUI for AJAX Replace

YUI for AJAX Replace

Posted:2007-08-14 10:30
Tags:Web, JavaScript

Here's the same example as before but implemented using YUI rather than scriptaculous:

${h.select(
    "TopicSet-1.TopicID",
    option_tags=topic_options,
    onchange="callAJAX('%s','diseases-select'); return false;"%(
        h.url_for(controller="newstudy",
            action="disease_dropdown_fragment"),
    )
)}
<script type="text/javascript">
//<![CDATA[
function callAJAX(sUrl, replace){
    var callback = {
    success: function(o) {
        YAHOO.util.Dom.get(replace).innerHTML = o.responseText;
     },
    failure: function(o) {
        alert("Failed to retrieve required information.");
    }
}
sUrl = sUrl +'?TopicSet-1.TopicID='
sUrl = sURL+YAHOO.util.Dom.get('TopicSet-1.TopicID').value;
var transaction = YAHOO.util.Connect.asyncRequest('GET', sUrl,
       callback, null);
}
//]]>
</script>

(view source)

James Gardner: Home > Blog > 2007 > YUI for AJAX Replace