Using the Microsoft AJAX Library with PHP

Steve Marx has been working behind the scenes on building out a community project to create native PHP support for the Microsoft AJAX Library.  Today he released the first version.  He provides a ton of details in this post which I steal liberally from below.

First download ASP.NET AJAX or grab just the client side Microsoft AJAX Library

Second, check out the codeplex project

Third, code away -- you can contribute bugs, code and more at the CodePlex site -- I think this is pretty darn cool and when you think about this in terms of our FastCGI work on IIS things are getting very cool for developers in any language/platform.

Check out this HelloWorld sample code:

 

 <?php
 
require_once '../../dist/MSAjaxService.php';
 
class HelloService extends MSAjaxService
{
    function SayHello($name)
    {
        return "Hello, " . $name . "!";
    }
}
 
$h = new HelloService();
$h->ProcessRequest();
 
?>

index.html:

 <html>
<head>
<title>Hello, World!</title>
<script type="text/javascript" src="../../MicrosoftAjaxLibrary/MicrosoftAjax.js"></script>
<script type="text/javascript" src="HelloService.php/js"></script>
</head>
<body>
Name: <input id="name" type="text" />
<input type="button" value="Say Hello" onclick="button_click(); return false;" />
<br />
Response from server: <span id="response"></span>
</body>
<script type="text/javascript">
    function button_click() {
        HelloService.SayHello($get('name').value, function (result) {
            $get('response').innerHTML = result;
        });
    }
</script>
</html>

Definitely let us know what you think!