views:

101

answers:

1

Is there a way that you can pass in a javascript object to a yui aSync request or does it only accept a URI?

+1  A: 

A YUI2 AsyncRequest sends a HTTP request to a URL using the request type you specify.

You are free to append information as query parameters for a GET or POST, or to send it as POST data.

To do so you could write a simple for in loop to iterate over your object & create a query string that you can then either set as the POST data or append to your URL if sending a GET. Be sure to use encodeURIComponent on the components as you are building your string.

Tivac
I also found out you can use setForm to set a whole form data as the post parameters to an async request, and then you don't have to worry about forming a query string. I was hoping for a way to just pass a javascript object in as a parameter, and let yui format it into JSON data or magically build the query string, but you can't always get what you want :P.
stevebot