這兩個錯誤,我得到在Firefox的錯誤控制檯:錯誤:未捕獲的異常:[異常...「無效或非法字符串指定」
Error: Incorrect document format
Source file:
Row 1, column 45
Source code:
<div xmlns="http://www.w3.org/1999/xhtml"><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
Error: uncaught exception: [Exception... "An invalid or illegal string was specified" code: "12" nsresult: "0x8053000c (NS_ERROR_DOM_SYNTAX_ERR)" location: "http://127.0.0.1/WebLibThirdParty/JavaScript//jquery.js Line: 112"]
我的jQuery代碼很簡單:
$(document).ready(function() {
// when the #guest_details is clicked
$('#guest_details').click(function() {
var postedData = $('#guest-details-dialog-contents form').serialize();
var uri = '/';
$.ajax({
type: 'POST',
data: postedData,
url: uri,
success: function(data) {
// this works
alert(data);
// this doesn't work
alert($(data).html());
}
});
return false;
});
});
正如你所看到的,有問題的路線是:
alert($(data).html());
在Ajax回調。 PHP腳本返回有效的XHTML(作爲XML),所以我被這個問題所迷惑。
編輯:
好的。問題是AJAX返回XHTML。它將標籤更改爲HTML:
<br /> becomes <br>
<input type="text" name="someInput" /> becomes <input type="text" name="someInput">
and so on
好的,問題是,AJAX返回XHTML搞砸了。它交換
爲
等。我該如何解決這個問題? – 2010-09-29 10:30:08