PHP for Microsoft AJAX Library

Steve Marx has developed and released his project called PHP for Microsoft AJAX Library to coincide with ASP.NET AJAX 1.0. The Microsoft AJAX Library is a pure-JavaScript library that's used by ASP.NET AJAX but is also available as a separate download. Because it's pure JavaScript, it's not tied to ASP.NET on the backend. PHP for MS […]

Steve Marx has developed and released his project called PHP for Microsoft AJAX Library to coincide with ASP.NET AJAX 1.0.

The Microsoft AJAX Library is a pure-JavaScript library that's used by ASP.NET AJAX but is also available as a separate download. Because it's pure JavaScript, it's not tied to ASP.NET on the backend. PHP for MS AJAX is code to help you make use of the Microsoft AJAX Library from PHP applications. With this first Alpha release, it simply supports exposing PHP classes as AJAX-enabled web services, just as in ASP.NET applications. In fact, the generated proxies are identical to what you get from ASP.NET, meaning you can have full interoperability. (The same client-side code could connect to either an ASP.NET web service or a PHP service.)

Here's a simple "Hello World" example that will hopefully drive home just how simple this makes AJAX web service calls. Copied from the PHP for Microsoft AJAX Library homepage:

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

<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: 
</body>
<script type="text/javascript">
    function button_click() {
        HelloService.SayHello($get('name').value, function (result) {
            $get('response').innerHTML = result;
        });
    }
</script>
</html>

smarx.com

PHP, Microsoft, AJAX, Library, .NET