Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jquery-ui/2.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 raty函数不适用于ajax_Jquery_Jquery Ui_Jquery Mobile_Jquery Plugins - Fatal编程技术网

jquery raty函数不适用于ajax

jquery raty函数不适用于ajax,jquery,jquery-ui,jquery-mobile,jquery-plugins,Jquery,Jquery Ui,Jquery Mobile,Jquery Plugins,我正在使用ajax加载一些配方细节,并在每个配方中显示其等级。但我的代码不起作用。请看一下我的代码,如果可以,请帮助我。提前谢谢 $("#btnsearch").click(function(){ if($("#ing").val()=="") { alert("Please enter a comma separated list to search");

我正在使用ajax加载一些配方细节,并在每个配方中显示其等级。但我的代码不起作用。请看一下我的代码,如果可以,请帮助我。提前谢谢

$("#btnsearch").click(function(){                
            if($("#ing").val()=="")
            {
                alert("Please enter a comma separated list to search");
                return false;
            }   
            var ing = $("#ing").val();
            $.ajax({
                method: "POST",
                url: urlsearch,
                data: {"ing":ing},
                dataType: "json"
            }).done(function(recipes){
                var total_recipes = recipes.length;
                var str2 = "";
                var resp_details = "";
                if(total_recipes)
                {
                    var myid = 1;
                    var str_ing = "";
                    var length_str_ing = 0;
                    for(var i=0;i<total_recipes;i++)
                    {
                       // var _id = i+1;
                        //console.log(recipes[i]);
                        str_ing = recipes[i].ingredients.join("<br />");                            

                        str2+='<li><a href="#item'+myid+'"><img src="http://icuizine.com/image/wh/recipe/100/100/'+recipes[i].recipe_image+'" align="absmiddle" />&nbsp;&nbsp;'+recipes[i].title+'<span class="ratings" score="'+recipes[i].rating+'"></span></a></li>';
                        resp_details += '<div class="panel" data-title="'+recipes[i].title+'" id="item'+myid+'"><div style="width:100%;clear:both;margin-top:20px;text-align:center;"><img src="http://icuizine.com/image/wh/recipe/100/100/'+recipes[i].recipe_image+'" /></div><div style="margin-top:20px;width:100%;text-align:center;"><b>Cuisine:&nbsp;</b>'+recipes[i].category+'<br /><b>Calories:</b>&nbsp;'+recipes[i].calories+'<br /><br /><b>'+recipes[i].total_ingredients+' Ingredient(s)</b><br /><br />'+str_ing+'</div><div style="width:100%;clear:both;text-align:center;margin-top:20px;text-align:left;">'+recipes[i].about+'</div></div>';
                        myid = myid+1;

                    }
                    //console.log(recipes[0].title);                                                
                }
                var str = '<ul class="list">';
                str += str2;
                str += '</ul>';
                $("#recipes_list").html(str);
                $("#recipe_details").html(resp_details);
               setTimeout(function(){
                    $(".ratings").each(function(){
                        var score = parseFloat($(this).attr("score"));                    
                        $(this).raty({score:score});
                    });
                },500);
            });
        });
$(“#btnsearch”)。单击(函数(){
如果($(“#ing”).val()=“”)
{
警报(“请输入逗号分隔的列表进行搜索”);
返回false;
}   
var ing=$(“#ing”).val();
$.ajax({
方法:“张贴”,
url:urlsearch,
数据:{“ing”:ing},
数据类型:“json”
}).完成(功能(配方){
var total_recipes=recipes.length;
var str2=“”;
var resp_details=“”;
if(总配方)
{
var-myid=1;
var str_ing=“”;
变量长度=0;

对于(var i=0;i您得到的错误是什么?..您应该提供更多信息:“但是我的代码不起作用”它到底是如何不起作用的?是否有任何错误?什么是“raty”?如果它是一个提供评级的插件,为什么不链接到它的主页?总而言之,在jsfiddle.net上提供一个简单的页面示例将非常有帮助。很抱歉,信息不完整。它只显示了我没有解决任何问题。感谢你们所有人。@aishazafar,你们是如何解决的?请解释和回答你们的问题,以便未来的人们了解将从中受益。