The submit button will cause a full reload of the page. In many cases where you have to change forms this is not an issue. But what if you want to change only a part of the form and don’t want to rebuild the rest? That is what Ajax is used for. Clicking on a button will send a request to the application but will leave the page unchanged. The result however might change a part of the form. 


So let’s rewrite the simple sample, so that it will use an ajax event. 


To create an ajax event you have to assign a javascript and php event that have the same name. For a button we will use the onClick event. There is also a javascript event of the same name. 


  1. Set the button type of both buttons from ‘submit’  into ‘button’. 

  2. Go to the JS events and open the onClick event. This will open the Javascript editor and as you will see, the JavaScript code is generated immediately:


You need to invoke the Javascript event but you do NOT have to write it!

  1. Add the PHP events and remove the onSubmitFormBtn.



Now generate an run the code. It will have the same result, but now using ajax. As you can see, every button has Its own event so no need to check for ajax (as it is an ajax event) nor the button id.