0

Can anyone help me with this bit of code?

I can't understand why when I submit the form correctly the confirmation box appear only for an instant, while I want that it remain on the screen until I click on the close button https://code.sololearn.com/WriLF9bnDT6C/?ref=app

16th Jun 2021, 3:15 PM
RichardB
RichardB - avatar
7 odpowiedzi
+ 2
Richard no, with server only the time to display the response (hidding the congratulation message) may increase... default action on submit form is to make an http request by sending form and receiving a new page... you could disable default submiting and either defer the form submition to when the congratulation was closed (by doing myForm.submit() in the close event handler -- but that require you change name and id of submit button wich prevent using it) or better send form data through xml https request (ajax), so you only display the congratulation popup when successful... disabling submition safer would use event.preventDefault in addition to return false ^^
16th Jun 2021, 6:36 PM
visph
visph - avatar
+ 1
https://code.sololearn.com/WAB2yJzZ04Qc/?ref=app Your form disappears because the form can interact with the server but there is no server and neither does the server send any data so I think that's the reason.
16th Jun 2021, 3:47 PM
Eashan Morajkar
Eashan Morajkar - avatar
+ 1
So if there was a server would it work as I've imagined it? Also have you changed anything so that your copy has a slight different result from mine?
16th Jun 2021, 4:04 PM
RichardB
RichardB - avatar
+ 1
visph Thanks for the explaination. Sorry for the ignorance, i don't still know what ajax is. But anyway I believe I did the other thing you have suggested me. Give it a look if you can. Thanks again
17th Jun 2021, 1:21 PM
RichardB
RichardB - avatar
0
i don't know if it will work on a server because i don't have experience with servers and also i have only changed "result=true" to false in the interacting with server part
16th Jun 2021, 4:59 PM
Eashan Morajkar
Eashan Morajkar - avatar
0
ok, thanks a lot for the answer. I also have no experience, javascript is the first language I'm learning
16th Jun 2021, 5:02 PM
RichardB
RichardB - avatar
0
Richard yes, quickly looking / testing seems to work as expected :) ajax stand for asynchrounious javascript and xml... it's a way of making request to sever without leaving page (and make update related to new data fetched): https://en.m.wikipedia.org/wiki/Ajax_(programming)
17th Jun 2021, 1:27 PM
visph
visph - avatar