Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #36603
| Path | csiph.com!eternal-september.org!feeder.eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail |
|---|---|
| From | Ben Bacarisse <ben.usenet@bsb.me.uk> |
| Newsgroups | comp.lang.javascript |
| Subject | Re: AJAX form submitting question |
| Date | Mon, 13 May 2019 13:45:40 +0100 |
| Organization | A noiseless patient Spider |
| Lines | 35 |
| Message-ID | <871s12o74b.fsf@bsb.me.uk> (permalink) |
| References | <731219e2-70a0-401c-a6ae-f11fe1191dbc@googlegroups.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain |
| Injection-Info | reader02.eternal-september.org; posting-host="4cbdb3492756a662adac8f6f3c007930"; logging-data="16920"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18x6j8jHidiKnNrFffHRxPrrVIERLMoi28=" |
| Cancel-Lock | sha1:ewACVvcN7Ie5IrO6PrfrmywiNYw= sha1:UurtjCIcar3M+ejId9He6pNFplc= |
| X-BSB-Auth | 1.fbc34523016f805f6d11.20190513134540BST.871s12o74b.fsf@bsb.me.uk |
| Xref | csiph.com comp.lang.javascript:36603 |
Show key headers only | View raw
groovee@cyberdude.com writes:
> I wanted to know how to submit a form using AJAX, ie. without a
> refresh, searching took me to this page:
>
> https://www.sitepoint.com/community/t/ajax-onsubmit-form-not-working/29367/6
>
> I can't understand and have a question about post #6. In the beginning
> of the JS code, there is this:
>
> function ajaxFunction(e){
> e.preventDefault();
> blah blah
>
> , but right at the end, when "ajaxFunction" is actually CALLED, it's like this:
>
> f.onsubmit = ajaxFunction;
That's not a call. That just sets up what function /will/ be called if
and when a 'submit' event occurs.
You should probably read up on event handlers because they all rely on
the same basic pattern: the programmer simply says what function to call
when the events occurs although this is usually done using a call to
addEventListner these days.
> ie. WITHOUT AN ARGUMENT! So where does the "e" come from then, when
> the function is called?
When the event occurs (in this case a submit event), the handler
function (in this case ajaxFunction) is called with the event as the
argument.
--
Ben.
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
AJAX form submitting question groovee@cyberdude.com - 2019-05-13 04:25 -0700
Re: AJAX form submitting question Ben Bacarisse <ben.usenet@bsb.me.uk> - 2019-05-13 13:45 +0100
Re: AJAX form submitting question groovee@cyberdude.com - 2019-05-13 07:20 -0700
Re: AJAX form submitting question JJ <jj4public@vfemail.net> - 2019-05-14 02:21 +0700
csiph-web