나는이 같은 콜백 함수를 호출거야?은 정의되지 않은 함수 아니다 "라고
$(function() {
//get all the items
search.init('.result tbody tr');
search.parseresults(function(announcementID){
//query every single page
var myCompany = new company(announcementID);
myCompany.requestPage(function(){
//on response parse the data.
myCompany.parsedata()
var myPerson = new person(myCompany)
myPerson.getPhone(function(){
console.log('test')
});
})
});
});
그것은을 console.log ('테스트')와 마지막 콜백 년대입니다 . 문제
이는 getPhone 기능입니다 :
person.prototype.getPhone = function(callback){
this.attempt++
if(this.attempt === 1){
var who = this.lastname;
var where = this.adress+' '+this.postal;
}else if(this.attempt === 2){
var who = this.firstname+' '+this.lastname;
var where = this.adress+' '+this.postal;
}else{
var who = this.firstname+' '+this.lastname;
var where = this.adress+' '+this.postal;
var url = 'http://personer.eniro.se/resultat/'+who+'/'+where;
console.debug('')
//console.debug('fail')
console.debug(url)
console.debug(this)
return
}
var self = this;
var url = 'http://personer.eniro.se/resultat/'+who+'/'+where;
GM_xmlhttpRequest({
method: "GET",
url: url,
onload: function(data) {
data = $.parseHTML(data.response);
var vCard = $(data).find('.vcard')
if (vCard.length === 1){
var phone = vCard.find('.tel.row a').map(function(){
return this.text
}).get()
self.officePhone = phone[0];
if(phone.length > 1){
self.mobilePhone = phone[1];
}else{
self.mobilePhone = '';
}
callback();
} else if(vCard.length > 1){
self.getPhone()
}
}
})
}
가에 생각하지만 콜백이있을 때 나는 오류를 얻을 때 콜백이 트리거됩니다 :.
당신이 다음 시도를하고있는 경우undefined is not a function
는 관련이없는 내용을 생략하는 코드를 단순화 할 수 있습니까? 기회는 다음과 같이 스스로 문제를 찾을 수 있습니다 :) – andreister