2

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.

1
  • You can do this using Ajax. If you use jQuery, you can use the $.ajax() function, which I find a lot less clunky than the pure JS approach. Commented May 14, 2015 at 20:44

1 Answer 1

1

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).

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks much to both of you. That is sounding right, and I think I have the idea now. I'll dive into it.. Looks like a new world though... learning curve. :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.