WayneF
WayneF

Reputation: 255

Spawn server cgi from html Javascript, at load time?

I have HTML and Javascript that passes Form Input variables to a server Perl cgi that works when Form Submit button is clicked (Post, Action, etc). I write it, but not much experience in that environment.

Question is, I want the cgi to be spawned automatically (hopefully silently) when the HTML page is loaded. The Javascsript runs when loaded, but is there a way for it to then call the server cgi automatically (and pass the Form variables), without the form Submit button? I fear Form requires Submit, but any exceptions? Or alternately, I know how to pass a parm string to the cgi, but I don't know how to spawn it automatically from Javascript? Typing http://...cgi spawns it, but automatically?

The cgi does have the option to "show no print" on screen, silently, in which case, can it run asynchronously, without needing a "return" back to restore the browser control? Cgi could return via a spawn of the referrer page (a second load)? But is that necessary? As is, because of the printed screen from Submit, it does need a manual return.

Everything else is working, but both the automatic spawn and the silent return are a puzzle? Ideas appreciated.

Upvotes: 2

Views: 95

Answers (1)

Vadim Pushtaev
Vadim Pushtaev

Reputation: 2353

If I understand the question correctly, you want to send a request to a server on page load.

You can do it pretty simple and straightforwardly via Javascript since submitting a form is not the only way to send a request. What you want is called AJAX.

If you use jQuery, read about ready and ajax.

If you don't use jQuery, there is still a way to execute any Javascript on page load and to send a request (but you still better consider using jQuery).

Upvotes: 1

Related Questions