"Creating an html file" is a task that a server side engine completes. "Inserting values to HTML" to keep a similar layout is what a templating engine does, which sounds like what you'd like to do. "AJAX" updates on a page, are usually more simplistic updates in the context you're defining them "single, or a few element updates or value insertions. These typically occur on an event within the page, or on a document event like 'when document is ready' then do this(jQuery)."
There are differences between each of the processes in many ways. For example, AJAX can be limited by CORS and sometimes allowing cross site scripting is something you have to configure within your server. AJAX is best used within the same web application and typically is used in the front end or "browser side code" of an application.
Templating engines are typically used on the server side, with the exception of some engines like Angular, which uses a sort of "templating-functions" process with some back end and front end code to offer an all around solution. (Angular 1.0 is a pretty widely used framework for this, and it works well with jQuery which allows the use of much less complex AJAX within your page, and on the fly updates and event actions)
Lastly, I've used CMS(Content Management Systems) that pre-render your page and all the required assets, such as database calls. A CMS will take a group of files and data and send them out to the client(browser) as different pages, but those are typically mapped out and defined in the back end if you manage your own CMS, and in a dashboard if your CMS is like wordpress.
To summarize in closing, there is no one "better" way. That question is globally referential to your assets, goals, current capabilities, environment, end product, and end users. Typically a straight forwards webapp that ends up being marketable uses something like the MEAN stack, which provides you with M - MongoDB(your database) E - Express(your page server, possibly your middleware) A - Angular (your routing/templating/etc) N - NodeJS(your terminal like access to the file system and http protocols)
the benefit to the MEAN stack being it's entirely JavaScript so learning all 4 specific components is much easier concurrently than it is separately.
I hope that helps, try not to ask such beginner questions at stack overflow however as you will receive many down votes on general guidance questions like this. For more information on the MEAN stack, please visit (http://mean.io/#!/) I think what you will learn there will really serve you well in creating the end product you're aiming for.