Skip to content

Latest commit

 

History

History
139 lines (100 loc) · 4.38 KB

queryToObject.rst

File metadata and controls

139 lines (100 loc) · 4.38 KB

dojo.queryToObject

since

V0.9

Helper function for converting a URI query string to a JavaScript Object

Introduction

This function is one of many helpers used by the dojo Xhr subsystem for handling AJAX style requests. This particular function takes the query portion of a URI and returns a JavaScript object of the name/value pairs. It handles both single and multi-valued query parameters. This function is useful in deconstructing URIs for display in page forms and the like. It can also be used as a way to modify a query by converting to JavaScript, making changes to parameters, then converting it back to a query string via dojo.objectToQuery <dojo/objectToQuery>

Since Dojo 1.7, dojo.queryToObject is exposed via the queryToObject method of the dojo/io-query module. An alias is kept in dojo/_base/xhr for backward-compatibility.

Usage

Usage is simple and straightforward, you pass the query string of the URI as the parameter to the function and it will return it in JavaScript object form.

Dojo 1.7+ (AMD)

Dojo < 1.7

Examples

Example 1: Using queryToObject to create a JavaScript form of a query

Example 2: Using queryToObject to alter query strings

See also

  • dojo.objectToQuery <dojo/objectToQuery>
  • dojo.formToQuery <dojo/formToQuery>
  • dojo.formToObject <dojo/formToObject>
  • dojo.formToJson <dojo/formToJson>