Question about formatQueryString behavior

May 24, 2011 at 7:59 AM

Looking at the documentation, it appeared that setting the formatQueryString property will automatically append $format=x to the request url.

Quoting from the documentation:

"formatQueryString: this is a query string option inserted in the URL."


However, from the source code it doesn't appear this is the case.  formatQueryString is only appended when you use JSONP (line 806 of datajs-0.0.3.js).  What if I didn't want to use JSONP but still wanted datajs to append the format string everytime I made a request?  Currently there doesn't seem to be a way other than manually inserting $format=json into the request uri.


Should formatQueryString be used everytime you made a request, regardless if JSONP is true or not?

May 24, 2011 at 10:54 PM

Jonathan, the formatQueryString was designed specifically for JSONP - that's the section where we put it in the documentation, but clearly we can do better with the name :)

It's really meant to name the format option for cases where the server calls it something different.

For a general-purpose mess-with-request mechanism, it's pretty easy to intercept the requests before they go out to the network. I just uploaded a short sample on how to do this.

Hope this helps,