NAVmoble - the pocket-sized ERP
Optimized for Microsoft Dynamics NAV and Windows Mobile powered devices

Sunday, October 29, 2006

AJAX and Pocket PC

Having my Vista gadget from my previous posts(1,2), I decided to see if I'll be able to monitor the status of my Cruise Control.NET projects from my Pocket PC.

My Pocket PC is running WM2003 SE and hopefully it turns out to be possible.



PocketIE provides support for Ajax, however in order to run the javascript code from the CC.NET gadget some changes should take place:

  • All invocation to the SideBar Gadget API should be removed. It includes all System.Gadget.Settings.read and System.Gadget.Settings.write statements
  • The XmlHttpRequest instance creation should be done by creating an ActiveX object(See example bellow)
  • PocketIE does not support setInterval , so it may be replaced with setTimeout. It must be called again and again on every successful postback in order to get a similar behavior

The XmlHttpRequest instance may be created with the following code:


xmlHttp = false;
try
{
xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
}
catch (error1)
{
try
{
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
catch (error2)
{
}
}

You may download the source code from here

Links:
Pocket IE and Ajax 1(IEMobile Team blog)
Pocket IE and Ajax 2(IEMobile Team blog)
IEMobile Team blog

No comments: