显示变量在ajax响应中不起作用 [英] Show variable is not working in ajax response

查看:42
本文介绍了显示变量在ajax响应中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

success: function (response) {
    var paid = "PURCHASED";
    var notpaid = "PREMIUM";
    $.each(response['courceResults'], function(k, cource) {
courceResultsData +='<tr><td>'
    if(cource.membership_chosen == 3){
    if ( $.inArray( cource.id , mystr ) != -1)  { /*alert(paid);*/ paid  } 

在上面的行中,当我警告即将到来的值时出现错误 正确的 ;但是当类型变量或在以下情况中保留字符串"PURCHASED"时 条件无法正常工作,我可以解决此串联问题..?

In the above line there is an error when i alert the value it is coming correct ; but when type variable or kept a string "PURCHASED" in if condition it is not working fine i resolve this concatenation..?

       else{ notpaid  }
    '</td></tr>';
   }); 

推荐答案

代码中的一些更正:-

success: function (response) {
    var paid = "PURCHASED";
    var notpaid = "PREMIUM";
    $.each(response.courceResults, function(k, cource) { //i think it's response.courceResults not response['courceResults'] check and change accordingly
        var courceResultsData ='<tr><td>'; // missed ;
        if(cource.membership_chosen == 3){
            if ( $.inArray( cource.id , mystr ) != -1){  // from where the hell mystr is coming? check yourself
                courceResultsData +=paid; // forgot concatenation
            } else{ 
                courceResultsData +=notpaid ; // forgot concatenation and missed ;  
            }
            courceResultsData +='</td></tr>';//forgot concatenation
        } // missed
    } // missed
    console.log(courceResultsData); //check the final output
} // missed

这篇关于显示变量在ajax响应中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆