红宝石,ajax中的搜索功能

There is a search button for searching name, but the function does not work, The following is the coding source:

_site_categories.html.erb

function find_category_by_name() {   
    $("img#loader").show();   
    $.ajax({  
        url: "<%= find_category_by_name_url %>",   
        type: "POST",   
        data: { code: $("input[type='text']#name").val() },   
        success: function(resp) {  
            if (resp) {  
                $("label#find_category_id").text(resp.category.id);   
                $("input[type='hidden']#name").val(resp.category.name);   
                enable_next_button();   
            } else {   
                $("label#find_category_id").text("Did not found.");   
                $("input[type='hidden']#name").val("");   
                disable_next_button();    
            }   
        },   
        complete: function() {   
            $("img#loader").hide();   
        }   
});   
}    

site_step_1.html.erb:

if (value2) {    
        $.ajax({    
            url: "<%= save_site_step_params_url %>",   
            type: "POST",   
            data: { site_category_name: value },  
            success: function(resp) {  
                window.location.href = "<%= site_step_2_url %>";  
            }  
        });     
    } else {     
        alert("Please select the type of website you are creating and the subcategory to activate the next step.");     
    }