
- Prototype 教程
- Prototype - 首頁
- Prototype - 簡要概述
- Prototype - 有用功能
- Prototype - 實用類方法
- Prototype - 元素物件
- Prototype - 數值處理
- Prototype - 字串處理
- Prototype - 陣列處理
- Prototype - 雜湊處理
- Prototype - 基本物件
- Prototype - 模板
- Prototype - 列舉
- Prototype - 事件處理
- Prototype - 表單管理
- Prototype - JSON 支援
- Prototype - AJAX 支援
- Prototype - 範圍表達
- Prototype - 定期執行
- Prototype 有用資源
- Prototype - 快速指南
- Prototype - 有用資源
- Prototype - 討論
原型 - 雜湊 toQueryString() 方法
此方法將雜湊轉換為其 URL 編碼查詢字串表示。
這是一種序列化形式,主要用於為 Ajax 名稱空間(例如 Ajax.Request)中的物件等內容提供複雜的引數集。
未定義值對將被序列化,就好像它們為空值一樣。陣列值對將針對每個陣列元素序列化為一個名稱/值對。所有值都使用 JavaScript 的原生 encodeURIComponent 函式進行 URI 編碼。
語法
hash.toQueryString();
返回值
返回 URL 編碼查詢字串。
示例
<html> <head> <title>Prototype examples</title> <script type = "text/javascript" src = "/javascript/prototype.js"></script> <script> function showResult() { var h = $H({action:'ship',order_id:123,fees: ['f1', 'f2']}); alert( "h.toQueryString() : " + h.toQueryString() ); } </script> </head> <body> <p>Click the button to see the result.</p> <br /> <br /> <input type = "button" value = "Result" onclick = "showResult();"/> </body> </html>
輸出
prototype_hash_processing.htm
廣告