Banglasavvy

Savvy News And Views

Programming

PHP for Microsoft AJAX Library – Microsoft busy with PHP

With the release of Microsoft AJAX ASP.NET 1.0, Steve Marx working on a project, a small library to help PHP applications make use of the Microsoft AJAX Library!

“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.” told Steve Marx.


The initial release of PHP for Microsoft AJAX Library currently supports creating web service proxies in PHP code such that the Microsoft AJAX Library can call them from client-side code. Future releases will support localization and globalization, debug and release scripts, and more features inspired by ASP.NET AJAX. PHP for Microsoft AJAX Library is in its alpha stage and require PHP 5.2 for json_encode/json_decode or you can manually install php-json. [Source: Ajax Magazine]

Here’s a “Hello World” example:

HelloService.php:

<?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>

One Comment

  1. Many thanks for sharing your opinion here. I really like it.

  Comments are closed.