gpt4 book ai didi

javascript - 显示变量在 ajax 响应中不起作用

转载 作者:行者123 更新时间:2023-11-30 15:28:48 25 4
gpt4 key购买 nike

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>';
});

最佳答案

您的代码中的一些更正:-

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

关于javascript - 显示变量在 ajax 响应中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42548016/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com