views:

132

answers:

2

Hi All..

How can we GET/POST the request to server with scriptaculous.js or prototype.js. Please explain with brief example if possible..

Regards, Akash Jain

+1  A: 

Here it is. It's a common usecase and thus very prominent in the documentation for Prototype.

Introduction to Ajax
http://www.prototypejs.org/learn/introduction-to-ajax

David Dorward
+1  A: 

You ca use Ajax.Request to send Ajax requests to your server (must be on the same domain name). For instance (quoting the doc) :

new Ajax.Request('/some_url', {
  method: 'get',
  parameters: {company: 'example', limit: 12}
  });

And, for POST, replace 'get' by 'post' ;-)

See :


Note that this can be used only to send request to a script on your own domainname, because of the Same Origin Policy implemented in web browsers for security reasons.

If you want to send requests to another domain, you'll have to go through a proxy installed on your own (so the request seems to be sent to your domain).


Scriptaculous is an "effects" framework, to do stuff like animations, drag'n drop, and that kinf of things.

It uses Prototype, but doesn't provide any Ajax-requesting functionnaly : it only uses those of Prototype, when necessary.

Pascal MARTIN