Many people have already answered this question however, in my case it's a little bit tricky.
I have 4 different place to put returned data from my ajax from 4 different files.
I am looking for a code like this :
function httpBB(file,id){
httpRequest.onreadystatechange = loadTicket(id);
httpRequest.open('POST', 'assets/php/'+file+'.php');
httpRequest.send();
}
file represent the file received by ajax and id represent the id of the div in my html.
Thanks for the help
Tom
Finally i find this way
not the better one but it works.
function httpBB(file){
switch (file) {
case 'ticket_new':
httpRequest.onreadystatechange = loadTicketNew;
break;
case 'ticket_my':
httpRequest.onreadystatechange = loadTicketMy;
break;
case 'ticket_current':
httpRequest.onreadystatechange = loadTicketCurr;
break;
case 'ticket_all':
httpRequest.onreadystatechange = loadTicketAll;
break;
default:
break;
}
httpRequest.open('POST', 'assets/php/'+file+'.php');
httpRequest.send();
}
function loadTicketNew(){
loadTicket('new')
}
function loadTicketMy(){
loadTicket('my')
}
function loadTicketCurr(){
loadTicket('new')
}
function loadTicketAll(){
loadTicket('my')
}
If someone find something better than this solution, thanks, but for now I will tuse this sh**
Have a nice day