This code gives the error "Cannot call method of undefined" what to do?)

$.ajax({ type: "POST", url: path_shell, cache:false, data: { flag_iq: 2, id_quest: iq_id[Tests.iq_question_number], masslenght: iq_id.length, number: Tests.iq_question_number }, success: setTimeout(function(data){ $('#preloader').hide(); var arr = data.split(['!##!'],[4]); $('#numer').html(arr[1]); $('#main_iq').html(arr[2]) ; if (iq_id[Tests.iq_question_number] in Tests.iq_answer) { var a=Tests.iq_answer[iq_id[Tests.iq_question_number]]; console.log(a); $('body').find('#'+a).addClass('checked'); },1000) 
  • @ Mihail2342, look in the debugger which line causes an error and write here. - VenZell

1 answer 1

Your code is delusional, you pass in not the function in success, but the result of the execution of setTimeout, i.e. his id and when it works, it naturally falls with an error on the line var arr = data.split(['!##!'],[4]); because date in this case will be undefined .