Submitting the form without refreshing the page is used on more sites than other types of JavaScript. This process allows the user to stay on the current page without losing their positioning on the page.
Take Facebook, for example. If this technology were not available, you would lose your spot on the page every time you comment on someone else's post. And as websites get bigger and with more users online making posts, it will only worsen, and that is where [Ajax] comes in to soothe the beast we call the Internet.
Using this AJAX script, we have to do something a little different from what we would normally do when passing data to our back-end processing page. We will need to have a hidden field with an ID value that we can pass through our AJAX to our back-end.
First, we have our button, and since AJAX cannot get the value of a button, we will need to do some JavaScript trickery to get its value to pass along.
This is where the Hidden field comes in. We will get the value from the Submit button of "Code" and then it to our page. This way, we can use code like this: