aboutsummaryrefslogtreecommitdiff
path: root/files/zh-tw/web/api/formdata/get/index.html
diff options
context:
space:
mode:
Diffstat (limited to 'files/zh-tw/web/api/formdata/get/index.html')
-rw-r--r--files/zh-tw/web/api/formdata/get/index.html145
1 files changed, 145 insertions, 0 deletions
diff --git a/files/zh-tw/web/api/formdata/get/index.html b/files/zh-tw/web/api/formdata/get/index.html
new file mode 100644
index 0000000000..b234ecb551
--- /dev/null
+++ b/files/zh-tw/web/api/formdata/get/index.html
@@ -0,0 +1,145 @@
+---
+title: FormData.get()
+slug: Web/API/FormData/get
+translation_of: Web/API/FormData/get
+---
+<p>{{APIRef("XMLHttpRequest")}}</p>
+
+<p>{{domxref("FormData")}} 的  <code><strong>get() </strong></code>方法會返回 <code>FormData 物件中,</code>指定 key 值所對應之第一組物件中的 value 值 。然而,如果您想要獲得多組以及全部的 value ,那應該使用 {{domxref("FormData.getAll()","getAll()")}} 方法。</p>
+
+<p><strong>注意</strong>:  這個方法已可以在 <a href="/en-US/docs/Web/API/Web_Workers_API">Web Workers</a> 中使用。</p>
+
+<h2 id="語法">語法</h2>
+
+<pre>formData.get(name);</pre>
+
+<h3 id="append()_Parameters" name="append()_Parameters">參數</h3>
+
+<dl>
+ <dt><code>name</code></dt>
+ <dd>一個 {{domxref("USVString")}} ,代表您想要得到的 value 所對應的 key 值名稱。</dd>
+</dl>
+
+<h3 id="回傳值">回傳值</h3>
+
+<p>A {{domxref("FormDataEntryValue")}} containing the value.</p>
+
+<h2 id="範例">範例</h2>
+
+<p>下面一行程式會產生一個空的 <code>FormData 物件:</code></p>
+
+<pre>var formData = new FormData();</pre>
+
+<p>用 {{domxref("FormData.append")}} 方法新增兩組 <code>username 值</code></p>
+
+<pre>formData.append('username', 'Chris');
+formData.append('username', 'Bob');</pre>
+
+<p>接下來使用 <code>get() 方法,將只會返回上一步驟,第一組新增的 username 所對應的值</code></p>
+
+<pre>formData.get('username'); // Returns "Chris"</pre>
+
+<h2 id="規範">規範</h2>
+
+<table>
+ <tbody>
+ <tr>
+ <th scope="col">規範</th>
+ <th scope="col">狀態</th>
+ <th scope="col">註解</th>
+ </tr>
+ <tr>
+ <td>{{SpecName('XMLHttpRequest','#dom-formdata-get','get()')}}</td>
+ <td>{{Spec2('XMLHttpRequest')}}</td>
+ <td> </td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="瀏覽器相容性">瀏覽器相容性</h2>
+
+<div>{{CompatibilityTable}}</div>
+
+<div id="compat-desktop">
+<table class="compat-table">
+ <tbody>
+ <tr>
+ <th>Feature</th>
+ <th>Chrome</th>
+ <th>Firefox (Gecko)</th>
+ <th>Internet Explorer</th>
+ <th>Opera</th>
+ <th>Safari</th>
+ </tr>
+ <tr>
+ <td>Basic support</td>
+ <td>{{CompatChrome(50.0)}}</td>
+ <td>{{CompatGeckoDesktop('39.0')}}</td>
+ <td>{{CompatNo}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatNo}}</td>
+ </tr>
+ <tr>
+ <td>Available in web workers</td>
+ <td>{{CompatChrome(50.0)}}</td>
+ <td>{{CompatGeckoDesktop('39.0')}}</td>
+ <td>{{CompatNo}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatNo}}</td>
+ </tr>
+ </tbody>
+</table>
+</div>
+
+<div id="compat-mobile">
+<table class="compat-table">
+ <tbody>
+ <tr>
+ <th>Feature</th>
+ <th>Android</th>
+ <th>Android Webview</th>
+ <th>Firefox Mobile (Gecko)</th>
+ <th>Firefox OS (Gecko)</th>
+ <th>IE Mobile</th>
+ <th>Opera Mobile</th>
+ <th>Safari Mobile</th>
+ <th>Chrome for Android</th>
+ </tr>
+ <tr>
+ <td>Basic support</td>
+ <td>{{CompatNo}}</td>
+ <td>{{CompatChrome(50.0)}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatNo}}</td>
+ <td>
+ <p>{{CompatVersionUnknown}}</p>
+ </td>
+ <td>{{CompatNo}}</td>
+ <td>{{CompatChrome(50.0)}}</td>
+ </tr>
+ <tr>
+ <td>Available in web workers</td>
+ <td>{{CompatNo}}</td>
+ <td>{{CompatChrome(50.0)}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatNo}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatNo}}</td>
+ <td>{{CompatChrome(50.0)}}</td>
+ </tr>
+ </tbody>
+</table>
+</div>
+
+<h2 id="sect1"> </h2>
+
+<h2 id="延伸閱讀">延伸閱讀</h2>
+
+<ul>
+ <li>{{domxref("XMLHTTPRequest")}}</li>
+ <li><a href="/en-US/docs/DOM/XMLHttpRequest/Using_XMLHttpRequest" title="Using XMLHttpRequest">Using XMLHttpRequest</a></li>
+ <li><a href="/en-US/docs/DOM/XMLHttpRequest/FormData/Using_FormData_Objects" title="DOM/XMLHttpRequest/FormData/Using_FormData_objects">Using FormData objects</a></li>
+ <li>{{HTMLElement("Form")}}</li>
+</ul>