tags:

views:

96

answers:

1

Hello,

I need help with this code because for some reason I don't get the data back It is probably something that got mixed up, because I never used xml with an ajaxcall

Could someone check if they see something going wrong here

function updateGebruikersonline(){
 //voor het fade effect
 gebruikerslijst.hide();
 loading2.fadeIn(2000, function () {
  //stuur de post variabelen naar livetabs.php
  $.ajax({
   type: "POST", url: "/includes/livetabs.php", data: "actie=gebruikersonline",
   complete: function(xml){
    loading2.fadeOut(2000);
    gebruikerstoevoegen(xml);
   }
   ,error: function(XMLHttpRequest, textStatus, errorThrown) { 
    if(textStatus == 'timeout') { 
     berichtlijst.html(fout).fadeIn(2000);
    }else if (textStatus == 'error'){
     berichtlijst.html(fout).fadeIn(2000); 
    } 
   }
  });//EINDE ajax
 });//EINDE callback loading
}

Edited: because I found the answer

I completely overlooked that I had to use this line in the php file, so that the browser will recognize it as xml.

 //php
    header('Content-Type: application/xml; charset=ISO-8859-1');

thanks, Richard

+1  A: 

Here you can find full reference and I think you need to use success property and not complete, since it has different semantic.

function updateGebruikersonline(){
        //voor het fade effect
        gebruikerslijst.hide();
        loading2.fadeIn(2000, function () {
                //stuur de post variabelen naar livetabs.php
                $.ajax({
                        type: "POST", url: "/includes/livetabs.php", data: "actie=gebruikersonline",
                        success: function(xml){
                                loading2.fadeOut(2000);
                                gebruikerstoevoegen(xml);
                        }
                        ,error: function(XMLHttpRequest, textStatus, errorThrown) { 
                                if(textStatus == 'timeout') { 
                                        berichtlijst.html(fout).fadeIn(2000);
                                }else if (textStatus == 'error'){
                                        berichtlijst.html(fout).fadeIn(2000);   
                                } 
                        }
                });//EINDE ajax
        });//EINDE callback loading

If you do want to use complete, so you need to write:

                        complete: function(response){
                                loading2.fadeOut(2000);
                                gebruikerstoevoegen(response.responseXML);
Artem Barger
no success yet. I know I used xml before with the post function, but know it will not work??I get nothing back in the xml object
I still get nothing with complete either.Causing more errors also.because it diddn't make it to my second debug alert.
try data: {actie : gebruikersonline}
Artem Barger
Do you able to see xml result in firebug for instance?
Artem Barger
I edited my question so it will include all.The main thing going on, is that I keep getting an empty xml object back.
Look, you have better install firebug, since you need to check that you receive something at all from the server, because maybe the server side is not working.
Artem Barger
Thanks for your help, ArtemI found the answer. I put it in the question above.