Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/76.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery ruby、ajax中的搜索功能_Jquery_Ruby_Ajax_Erb - Fatal编程技术网

Jquery ruby、ajax中的搜索功能

Jquery ruby、ajax中的搜索功能,jquery,ruby,ajax,erb,Jquery,Ruby,Ajax,Erb,有一个搜索按钮用于搜索名称,但该功能不起作用,以下是编码源: _网站_categories.html.erb function find_category_by_name() { $("img#loader").show(); $.ajax({ url: "<%= find_category_by_name_url %>", type: "POST", data: { code: $("inp

有一个搜索按钮用于搜索名称,但该功能不起作用,以下是编码源:

_网站_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();   
        }   
});   
}    
函数通过名称()查找类别{
$(“img#loader”).show();
$.ajax({
url:“”,
类型:“POST”,
数据:{code:$([input[type='text']#name”).val(),
成功:功能(resp){
如果(resp){
$(“label#find_category_id”).text(resp.category.id);
$(“input[type='hidden']#name”).val(resp.category.name);
启用下一个按钮();
}否则{
$(“label#find#u category_id”)。文本(“未找到”);
$(“输入[type='hidden']#name”).val(“”);
禁用下一步按钮();
}   
},   
完成:函数(){
$(“img#loader”).hide();
}   
});   
}    
站点_步骤_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.");     
    }
如果(值2){
$.ajax({
url:“”,
类型:“POST”,
数据:{site\u category\u name:value},
成功:功能(resp){
window.location.href=“”;
}  
});     
}否则{
提醒(“请选择您正在创建的网站类型和要激活下一步的子类别。”);
}

应始终引用数据,包括键和值欢迎使用堆栈溢出!当你说“功能不工作”是什么意思?你的JS控制台有错误吗?当我点击“搜索”按钮时,它有一个持续几秒钟的加载图标。网站没有任何变化