On Thu, Sep 29, 2011 at 2:37 PM, Rajeev Prasad <rp.ne...@yahoo.com> wrote: > i am simply trying to find a tool/module/method (as in English > word method) which would allow asynchronous XMLHTTPRequest to > be sent to perl CGI programs on my web server (or sub routines > in a perl script) and return the value(s) to webpage to be > displayed in the div i want to display on.
AJAX is most often used as a buzzword. The actual definition is Asynchronous JavaScript And XML. The key is the XMLHttpRequest object in JavaScript (a non-standard browser extension), which allows code to make a Web request in the background (asynchronously) without affecting the current page. The result of that request may be XML data, but often JSON is used instead of XML because it's simpler and usually smaller (the term AJAX is often used anyway). You can also choose to just return plain HTML too instead of data. The server doesn't actually /need/ to do anything special for this. The AJAX part can be completely implemented in client-side JavaScript. Then it's a matter of having server-side code that returns the right response, whether that's a snippet of HTML, an entire HTML document, or some data format. The server doesn't necessarily need to expect to be used asychronously, though it often does for efficiency's sake (it's often more efficient to send data than an entire document). > i was wondering is this possible: [example from web, modified a > bit] *snip* Your example appears to be just fetching an HTML snippet from a Web server and inserting it into the DOM with JavaScript. Relatively little is needed on the server to do this. Which ever CGI program you invoke will need to know what you are asking for. It could be a specialized program that only handles one request type, or it could be a dispatcher that figures out what you want by GET or POST data and returns it appropriately. That is up to you. Whether the program outputs an HTML document, an HTML snippet, or some data format is also up to you. The client-side implementation will need to specially deal with whatever response type the server sends. I would recommend a JavaScript library, such as jQuery, to make things a little bit easier on the JavaScript side. As I said, the XMLHttpRequest object is non-standard, and some browsers do it a little bit differently. jQuery can also help to abstract other incompatibilities, like innerHTML and innerText. jQuery can be thought of as a cross-browser compatibility layer (with added sugar). There are other options, of course, but jQuery is just the one that I am familiar with. I personally haven't gotten around to doing any real CGI programming so I can't help out with that. Regards, -- Brandon McCaig <http://www.bamccaig.com/> <bamcc...@gmail.com> V zrna gur orfg jvgu jung V fnl. Vg qbrfa'g nyjnlf fbhaq gung jnl. Castopulence Software <http://www.castopulence.org/> <bamcc...@castopulence.org> -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/