2012年7月16日 星期一

Opera 在進行AJAX的……可以說是一個BUG吧……

最近作網站時,在進行瀏覽器測試時,有段AJAX的讀取,無論是IE(目前只測試了IE9、6)、firefox、chrome都沒問題,就是Opera有問題……

下面是錯誤訊息:
Opera/9.80 (X11; Linux x86_64; U; zh-tw) Presto/2.10.229 Version/11.64 (Core 2.10.229) 請用 "clear()" 指令來清理主控台。 輸入 "// help()" 則可取得更多資訊 Uncaught exception: DOMException: HIERARCHY_REQUEST_ERR Error thrown at line 4, column 9053 in <anonymous function: clean>(a, b, d, e) in {my domain}/js/jquery.js:     k++ called from line 4, column 5407 in <anonymous function: f.buildFragment>(a, b, d) in {my domain}/js/jquery.js:     b&&b[0]&&(i=b[0].ownerDocument||b[0]),i.createDocumentFragment||(i=c),a.length===1&&typeof j=="string"&&j.length<512&&i===c&&j.charAt(0)==="<"&&!bb.test(j)&&(f.support.checkClone||!bd.test(j))&&(f.support.html5Clone||!bc.test(j))&&(g=!0,h=f.fragments[j],h&&h!==1&&(e=h)),e||(e=i.createDocumentFragment(),f.clean(a,i,e,d)),g&&(f.fragments[j]=h?e:1); called from line 4, column 3855 in <anonymous function: domManip>(a, c, d) in {my domain}/js/jquery.js:     i=j&&j.parentNode,f.support.parentNode&&i&&i.nodeType===11&&i.childNodes.length===this.length?e={fragment:i}:e=f.buildFragment(a,this,k),h=e.fragment,h.childNodes.length===1?g=h=h.firstChild:g=h.firstChild; called from line 3, column 64779 in <anonymous function: append>() in {my domain}/js/jquery.js:     return this.domManip(arguments,!0,function(a){this.nodeType===1&&this.appendChild(a)}) called from line 4, column 2153 in <anonymous function: html>(a) in {my domain}/js/jquery.js:     c&&this.empty().append(a) called via Function.prototype.call() from line 2, column 26230 in <anonymous function: access>(a, c, d, f, g, h, i) in {my domain}/js/jquery.js:     j=i===b&&e.isFunction(f),k&&(j?(j=c,c=function(a,b,c){return j.call(e(a),c)}):(c.call(a,f),c=null)); called from line 4, column 1720 in <anonymous function: html>(a) in {my domain}/js/jquery.js:     return f.access(this,function(a){var c=this[0]||{},d=0,e=this.length;if(a===b)return c.nodeType===1?c.innerHTML.replace(W,""):null;if(typeof a=="string"&&!ba.test(a)&&(f.support.leadingWhitespace||!X.test(a))&&!bg[(Z.exec(a)||["",""])[1].toLowerCase()]){a=a.replace(Y,"<$1></$2>");try{for(;d<e;d++)c=this[d]||{},c.nodeType===1&&(f.cleanData(c.getElementsByTagName("*")),c.innerHTML=a);c=0}catch(g){}}c&&this.empty().append(a)},null,a,arguments.length) called from line 47, column 2 in <anonymous function: success>(result, status, xhr) in {my domain}/js/my_js_file.js:     $(".menu-bar").html(result); called via Function.prototype.apply() from line 2, column 29359 in <anonymous function: f.Callbacks>(b, f) in {my domain}/js/jquery.js:     if(c[m].apply(b,f)===!1&&a.stopOnFalse) called from line 2, column 30902 in <anonymous function: fireWith>(b, c) in {my domain}/js/jquery.js:     d&&(j?a.once||d.push([b,c]):(!a.once||!e)&&o(b,c));
我所讀取的是網頁的menu-bar,然後為了w3c的關係,我特意讓其顯示為text/plain。
<? header("Content-type: text/plain"); ?>
結果這就是問題……
Opera的AJAX判定好像挺嚴格的……
就因為我讀得不是html結果就一直有Error……
將其改為下面這樣(也就是追加「dataType: "text"」)即可……
$.ajax({
	url: "menu_bar.php",
	dataType: "text",
	success: function(result,status,xhr){
		//TODO function 
	}
});

沒有留言:

張貼留言