Jaslabs: High performance Software

High Performance Software

PHP library for Microsoft AJAX

By Justin Silverton

Microsoft has released their AJAX library package for non-windows systems which contains a complete set of client JavaScript components that are included in the full ASP.NET AJAX installation. Developers over at Codeplex have developed a library that allows you to integrate your PHP applications with this package.

requirements

  • PHP 5.2 — 5.2 is required for json_encode/json_decode; For earlier versions, you will need to install php-json

How to install

  1. Download the PHP library from codeplex here
  2. Download the Microsoft AJAX Library here
  3. After extracting both of these, place all the files from the Microsoft Ajax library in a directory called “MicrosoftAjaxLibrary”

Example

The following is a simple example that demonstrates a simple ajax transmission using the microsoft libraries.

(hello.htm)

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

(HelloService.php)

<?php

require_once '../../dist/MSAjaxService.php';

class HelloService extends MSAjaxService
{
function SayHello($name)
{
return "Hello, " . $name . "!";
}
}

$h = new HelloService();
$h->ProcessRequest();

?>

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • DZone
  • Slashdot
  • StumbleUpon
  • Technorati

1 Comment so far

  1. […] In a new post today, Justin Silverton points out a PHP library that makes available the full set of features that Microsoft previously only had for its ASP.NET language. Microsoft has released their AJAX library package for non-windows systems which contains a complete set of client JavaScript components that are included in the full ASP.NET AJAX installation. Developers over at Codeplex have developed a library that allows you to integrate your PHP applications with this package. […]

Leave a reply