Prototype-hash-toquerystring

提供:Dev Guides
移動先:案内検索

プロトタイプ-ハッシュtoQueryString()メソッド

このメソッドは、ハッシュをURLエンコードされたクエリ文字列表現に変換します。

これは、シリアル化の形式であり、Ajax名前空間のオブジェクト(例: Ajax.Request)。

未定義値のペアは、空値のようにシリアル化されます。 配列値のペアは、配列要素ごとに1つの名前/値のペアでシリアル化されます。 すべての値は、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>

出力