1

I have this code:

    var ajaxLoader = $('.ajaxLoader', lpWindow);
$.ajaxSetup({
    url: 'http://www.server.foo/setMessage.php',
    type: 'POST',
    data: {
        text: message,
        username: username
    },

    beforeSend: function(){
        ajaxLoader.fadeIn( 'fast' );
    },
    complete: function(){
        ajaxLoader.fadeOut( 'fast' );
    },
    success: function(){
        ajaxLoader.fadeOut( 'fast' );
    },
    error: function(xhr, ajaxOptions, thrownError){
        $('.content', lpWindow).empty().append('Something went wrong...');
        console.log(xhr.status);
        console.log(xhr.statusText);
        console.log(thrownError);

    }
});

$.ajax({
    success: function(){
        getMessages(lpWindow)
    }
});

It works perfect in Google Chrome but it fail in firefox. i get this error messages in firebug.

200 parsererror Invalid XML: 601

What's wrong and how can i solve it?

Sumurai8
  • 20,333
  • 11
  • 66
  • 100
Tord
  • 15
  • 1
  • 3

1 Answers1

1

It looks like the request succeeds but your XML in the response is invalid. Ensure you're sending back valid XML.

EDIT

If you're not actually sending back XML, make sure to set at least one of the following with right data type (the examples below are for JSON):

  • The Content-Type header on the server (header('Content-type: application/json'); for PHP)
  • The dataType parameter for the Ajax request (dataType:'json')
no.good.at.coding
  • 20,221
  • 2
  • 60
  • 51
  • I'm not allowed to edit the .php file. so i can't change anything in the .php. – Tord Mar 18 '11 at 15:46
  • @Tord Fair enough. But you haven't answered the basic question - what is the data that the PHP returns? Is it XML? Can you post a sample response to help debug? – no.good.at.coding Mar 18 '11 at 15:48
  • I do not have permission to change the php file. I tried putting dataType: 'xml', in the ajax request, but it did not solve the problem. – Tord Mar 18 '11 at 15:48
  • @Tord Ok, can you post a sample? And can you check that your XML is valid? Run it through an XML validator and see if it passes. – no.good.at.coding Mar 18 '11 at 15:51
  • http://j7.se/9cqwp - click on the green icon chat icon. i checked the manual for setMessage.php and it says: Address: http://adress.com/setMessage.php Method: POST Parameters: Text: Using this parameter is sent in the message text. username: Via this parameter is passed in the username. Return: If the message is stored properly, it will contain the response a unique ID for the message. – Tord Mar 18 '11 at 15:56
  • I took a look at the response - the content type being set by the server is `text/html` and not XML (although the text itself is well-formed XML); that's probably the root of your problem. But if using `dataType:'text'` works for you then great! – no.good.at.coding Mar 18 '11 at 16:08