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!

Comments (5)

  1. AJAX : The Official Microsoft ASP.NET AJAX Site ScottGu’s Blog ASP.NET AJAX 1.0 Released RC 버젼 공개 한달하고

  2. At the risk of sounding cynical, this appears to be just marketing spin.  Why else would someone use a framework that was intended for ASP.NET (heck – it has it in its name) for PHP when there are so many other established AJAX frameworks out there? (e.g. prototype).

    But I guess it all helps in the end.

    Now if I could only find an add-in for Visual Web Developer Express to do proper syntax highlighting of PHP code…

  3. Dflying Chen says:

    说明前面一个月一直都在翻译《ZenofCSSDesign》,ASP.NET英文技术文章推荐和digg.com网站Programming分类每周热点两个系列也中断了……不过翻译工作终于大功告成,…

  4. TheXenocide says:

    I would say that it would probably be to promote consistency within more complicated Enterprise Systems. Besides that, this actually looks like the Web Service side of the AJAX call, not necessarily the client interaction piece. I haven’t looked things over thoroughly, but at first guess i would say the above code returns results used by an AJAX call that is likely to initiate from an ASP.NET Site/Application. Even if it is a full fledged AJAX framework for PHP, wouldn’t it be nice to become familiar with a single system and be able to use it with any programming language?

    -Xeno

  5. Sentido Web says:

    ASP.NET AJAX, la librería Ajax de Microsoft, está disponible para los usuarios de PHP (si es que hay algún valiente que se atreva). La gente de Microsoft ha resarrollado un proyecto en Codeplex que sirve de puente entre PHP y…

Skip to main content