Microsoft Ajax Library on PHP


A reader asked about the reference to running part of ASP.NET AJAX on PHP\Apache in my recent interview… The specific thing I was talking about was running the Microsoft Ajax Library on PHP…

Check out the CodePlex project.. Feel free to jump in and contribute to it.

http://codeplex.com/phpmsajax 

Here is the “hello, world” for this project..

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

Oh, and if you are interest in PHP, you might want to check out the FastCGI work on IIS to make PHP rock on IIS7.

Enjoy!

Comments (9)

  1. PohEe.com says:

    If it works in PHP, then it works excellent for me in my WordPress project.

  2. Tim Jarvis says:

    Hi Brad,

    Firstly in the interests of disclosure, I work for CodeGear. I don’t want to hijack your blog for marketing, thats not my intent, but i think this is very relevant to your post, have you seen this yet http://www.codegear.com/Products/Delphi/DelphiforPHP/tabid/237/Default.aspx this (about to be released) product is going to rock the php/ajax world.

  3. Eric Ramseur says:

    Why not just use Phalanger and run any .NET code [ ajax included] in Php and vice versa?  They’ve put the php lib into a .NET language.

    Refer : http://tinyurl.com/24xo46

  4. As you may know, we have already announced that the IIS team was working with Zend to improve PHP performance

  5. Sagi Arsyad says:

    beberapa hari lalu, IIS meng-announce kerja sama dengan Zend Team untuk meningkatkan performa PHP di

  6. Dflying Chen says:

    摘要本期共有10篇文章:在ASP以及非ASP.NETURL中使用ASP.NET安全验证在PHP中使用MicrosoftAjaxLibraryOrcas版本C#语言的新特性:自动属性、对…

  7. Max Shumov says:

    " Oh, and if you are interest in PHP, you might want to check out the FastCGI work on IIS to make PHP rock on IIS7. "

    Thanks! I’ve just started to study PHP and I think that the more articles I’ll read, the better it’ll be for my styding. Am I right?

  8. Nikolay I. says:

    >I think that the more articles I’ll read, the better it’ll be for my styding. Am I right?

    Yes. You’re absolutly right! I’m studying php for half year, and I should say that I have confronted with difficulties, because I had wery few articles.

  9. Jacky_xu says:

    本期共有10篇文章: 在ASP以及非ASP.NETURL中使用ASP.NET安全验证

    在PHP中使用MicrosoftAjaxLibrary

    Orcas版本C#语言的新特…