- 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 - 討論
Prototype - Object toQueryString() 方法
此方法將物件轉換為其 URL 編碼查詢字串表示形式。
這是一種序列化形式,主要用於為某些物件(例如 Ajax 名稱空間中的物件(例如 Ajax.Request))提供複雜的引數集。
語法
Object.toQueryString(obj);
返回值
返回一個編碼字串。
例項
<html>
<head>
<title>Prototype examples</title>
<script type = "text/javascript" src = "/javascript/prototype.js"></script>
<script>
function showResult() {
var o = { action: 'ship', order_id: 123,
fees: ['f1', 'f2'], 'label': 'a demo' };
alert("URI: " + Object.toQueryString(o) );
}
</script>
</head>
<body>
<p>Click the button to see the result.</p>
<br />
<br />
<input type = "button" value = "Result" onclick = "showResult();"/>
</body>
</html>
輸出
prototype_basic_object.htm
廣告