James Gardner


YUI for AJAX Replace

Posted in Web, JavaScript by thejimmyg on the August 14th, 2007

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>

Leave a Reply