Does the Dreamhost API work with AJAX


#1

I want to use the Dreamhost API from a web page.

There is an example of this using a form with:

But I wish to be able to format the results and display
them on my web page. So I thought of using AJAX with a
callback function to do the display. But then I found
reference to the “same origin policy” which is enforced
by all modern browsers.

Does api.dreamhost.com support JSONP or Cross-origin
resource sharing (CORS)?


Api.dreamhost.com, AJAX, and CORS
#2

This isn’t really a use case we were thinking about — using the DreamHost API in a web page would mean that your API key is embedded in that page, making it available for anyone to see and use. Our expectation was that interaction with the API would stay on the server side. What exactly are you doing that’d require this?

For what it’s worth, if you just want to display the results, you can pass “format=html” to get a nice table back; e.g:

https://api.dreamhost.com/?key=6SHU5P2HLDAYECUM&cmd=api-list_accessible_cmds&format=html


#3

I would like to be able to send announcements to the announcement list with a browser based wysiwyg editor.
I intend to secure the web page in question with a password.


#4

Aha — I guess that makes sense. In any case, for this you should be able to just write the page as a plain-Jane HTML form that submits its input to the API:

<form method="POST" action="https://api.dreamhost.com/"> <input type="hidden" name="key" value="XYZZY"> <input type="hidden" name="format" value="html"> … <input type="submit">

When you submit the form, you’ll be sent to the results page, which will hopefully just say “success”.