# AJAX PHP - Call PHP Class



## MRdNk (Apr 7, 2007)

Hi All,

I'm in the process of learning AJAX. I have a good understanding of PHP and the OOP pattern. Currently using the w2schools w2schools example, which I've adapted and have working.

However, currently I request the PHP page to create an xml file with the relevant results returned, meaning that I would need a PHP page/file per query.

*Is it possible and how can I request a particular class from the PHP file?*
P.s. I'm also using MooTools, if anyone has a solution based around this framework.


```
var xmlHttp;
function showUser(str)
 { 
 xmlHttp=GetXmlHttpObject();
 if (xmlHttp==null)
  {
  alert ("Browser does not support HTTP Request");
  return;
  } 
 var url="responsexml.php";
 url=url+"?q="+str;
 url=url+"&sid="+Math.random();
 xmlHttp.onreadystatechange=stateChanged;
 xmlHttp.open("GET",url,true);
 xmlHttp.send(null);
 } ...
```
"var url="responsexml.php";" is the line & method, that needs a new solution.


----------



## MRdNk (Apr 7, 2007)

My solution atm, still looking for a better one, is to have the multiple PHP pages, but have it just call the class function in another PHP file which returns the results.

The overall point is to make the site as class based as possible. I'm building a PHP AJAX framework as much as a specific site.


----------

