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 }
在上面的代码行中,当我警告它的值是正确的时,有一个错误;但是当输入变量或者在if条件下保持一个字符串"PURCHASED“时,它不能正常工作,我解决了这个连接。
else{ notpaid }
'</td></tr>';
});
发布于 2017-03-02 14:17:05
在您的代码中进行一些更正:
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
https://stackoverflow.com/questions/42548016
复制相似问题