parseerror无效的XML:601
我有这个代码:
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) } });
它在Google Chrome中运行良好,但在Firefox中失败。 我在firebug中收到此错误消息。
200 parsererror无效的XML:601
怎么了,怎么解决呢?
看起来请求成功但响应中的XML无效。 确保您发回有效的XML。
编辑
如果您实际上没有发回XML,请确保使用正确的数据类型设置以下至少一个(以下示例适用于JSON):
- 服务器上的
Content-Type
标头(header('Content-type: application/json');
对于PHP) - Ajax请求的
dataType
参数(dataType:'json'
)