Forum How do I...?

JQuery ajax support

facboy
does Prince's javascript currently support JQuery GET/POST? i'm getting error No transport when trying to run it, but i'm not sure if this is a CORS problem or Prince not supporting this usage at the moment.
mikeday
No, initial support for AJAX is coming in the next release of Prince.
Mike
Which release would that be? :)
mikeday
Prince actually has very very limited support for AJAX already! But only GET requests. :)
Mike
Hi mikeday,

Great news!

Could you please point me to a sample code?
I was not able to find anything regarding this in User Guide section.

Are there any *hidden* documentation I'm not ware of? :)
mikeday
Here is a simple example for a GET request:
var x = new XMLHttpRequest();
x.open("GET", "http://www.princexml.com", no);
x.send();
alert(x.responseText);

There is no documentation for AJAX yet; we are planning to support more of the standard interface later.
Mike
Is it safe to assume that XMLHttpRequest and all his properties are supported?

Or is it only what's in the example?
mikeday
Pretty much only the example, maybe a couple of other properties, but all downloads are synchronous, only GET is supported, that's about it.
mikeday
Note: if this is too limiting, you could just use JavaScript to write to the output log or console and have an external script do something more complicated with the data.
Mike
That's what I'm doing, will read from console and then work on it.

This is a little bit of topic, but I'm thinking about speed. Is Prince CPU or RAM or equally both hungry?
mikeday
Difficult to answer that, as the units are not comparable. Easier to try running Prince on some sample documents and see how it goes. In general I guess it is better to have more RAM, as a slower cpu will just make the conversion take longer, but running out of RAM can make the conversion fail entirely.
Mike
Hi mikeday,

Thanks for the answer. Well I'm looking into AWS instances and you can get CPU or RAM optimized instances, that's the reason for this question.

I'll try to play around with samples, my goal is as fast as possible.

Mike