2017-03-02 9 views
1
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 } 

上記の行で、値が になると警告します。しかし変数を入力するか、文字列を "購入済み"の場合 状態ではうまくいきません。この連結を解決します.. ..?Show変数がajaxレスポンスで動作していません

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

あなたが問題にフィドルを提供することはできますか? – Mamun

答えて

2

あなたのコード内のいくつかの修正: -

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 
関連する問題