Your question shows that you misunderstood AJAX, Apache and Nginx.
AJAX is simply a technique for a browser to request some information from a server without refreshing the web page. It consists of an HTTP (or HTTPS) request sent by the browser to the server. For a web server such as Apache or Nginx, it makes technically little difference if the HTTP request is made through AJAX or not: it's still an HTTP request, and nothing more.¹
On server side, requests are somehow processed. They could lead to a static resource, such as a CSS file or a JPEG image or an HTML document stored somewhere on the server, or they can be dynamic, which means that they lead to the execution of the custom source code—it could be code written in Python, Ruby, Java, PHP, whatever. While nothing prevents you from having a static website which makes AJAX requests to static resources, frequently AJAX is associated with dynamic websites.
This leads us to the choice of the web server. Actually, what you were probably searching is if a given server can run your app written in a given language. For instance, LAMP bundle is well-known for allowing to run PHP websites using Apache; there is a strong support for it, and setting up the environment is relatively easy. Unsurprisingly, Nginx supports PHP too. However, more esoteric languages may have a better support on one server compared to another, and that would be important to know before determining which server you should actually use. note that FastCGI—the glue between web servers and programs—make it possible to develop web apps with virtually any programming language and host them on virtually any popular web server.
But there is a better alternative: try both Apache and Nginx, and see yourself which one fits better your needs!
¹ A slight specificity of AJAX requests is that they tend to be small but frequent. It is not inherent to AJAX itself—nothing prevents you from writing a web app which makes requests rarely, and receives a lot of data, but it is common to have AJAX-enabled apps to do a lot of tiny requests. This specificity could influence your choice of server infrastructure, would it be the actual web server or the reverse proxy, the version of HTTP, etc. However, don't focus on those aspects for now. Once you have a basic understanding of web servers, web apps and HTTP, only then those subjects would actually matter.