The type of data that you're expecting back from the server. If none is specified, jQuery will intelligently pass either responseXML or responseText to your success callback, based on the MIME type of the response. The available types (and the result passed as the first argument to your success callback) are:
"xml": Returns a XML document that can be processed via jQuery.
"html": Returns HTML as plain text; included script tags are evaluated when inserted in the DOM.
資料格式 (dataType) 介紹 ( 二 )
"script": Evaluates the response as JavaScript and returns it as plain text. Disables caching unless option "cache" is used. Note: This will turn POSTs into GETs for remote-domain requests.
"json": Evaluates the response as JSON and returns a JavaScript Object.
"jsonp": Loads in a JSON block using JSONP . Will add an extra "?callback=?" to the end of your URL to specify the callback. (Added in jQuery 1.2)
"text": A plain text string.
PHP 回傳資訊
以往透過 XMLHttpRequest 請求 PHP 回傳資訊時,時常出現以下問題:
資料格式: 瀏覽器可接受的資料格式種類眾多,伺服端回傳資料時需告知瀏覽器檔案類型,如 XML 資料需附加檔頭標記為 XML 文件;若為純文字格式傳回多筆資料時,則採用符號分隔 (*.csv) ,至瀏覽器時再依照符號分割取得資料。若無統一的解決方案,將可能造成各種自訂的回傳方式且難以維護。
0 comments
Post a comment