<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Alex Tsung's Weblog &#187; jQuery</title>
	<atom:link href="http://atsung.wordpress.com/category/jquery/feed/" rel="self" type="application/rss+xml" />
	<link>http://atsung.wordpress.com</link>
	<description>ASP.NET related</description>
	<lastBuildDate>Thu, 04 Jun 2009 07:09:30 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='atsung.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://www.gravatar.com/blavatar/d03430f7c9167f70228686d34687eb35?s=96&#038;d=http://s.wordpress.com/i/buttonw-com.png</url>
		<title>Alex Tsung's Weblog &#187; jQuery</title>
		<link>http://atsung.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://atsung.wordpress.com/osd.xml" title="Alex Tsung&#8217;s Weblog" />
		<item>
		<title>jQuery and ASP.NET AJAX PageMethods</title>
		<link>http://atsung.wordpress.com/2008/08/12/jquery-and-aspnet-ajax-pagemethods/</link>
		<comments>http://atsung.wordpress.com/2008/08/12/jquery-and-aspnet-ajax-pagemethods/#comments</comments>
		<pubDate>Tue, 12 Aug 2008 07:01:56 +0000</pubDate>
		<dc:creator>atsung</dc:creator>
				<category><![CDATA[jQuery]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Latitude]]></category>
		<category><![CDATA[Longitude]]></category>
		<category><![CDATA[Map]]></category>
		<category><![CDATA[PageMethods]]></category>
		<category><![CDATA[Web Services]]></category>
		<category><![CDATA[XmlHttpRequests]]></category>

		<guid isPermaLink="false">http://atsung.wordpress.com/?p=21</guid>
		<description><![CDATA[In ASP.NET AJAX there are two ways to make AJAX calls to retrieve data from server side &#8211; Web Services and Page Methods. For the project I am working on, based on the design and flexibility for page developers, I use PageMethods to query data from the server side and it worked well. But there [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=atsung.wordpress.com&blog=4439908&post=21&subd=atsung&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>In ASP.NET AJAX there are two ways to make AJAX calls to retrieve data from server side &#8211; <a href="http://www.asp.net/ajax/documentation/live/tutorials/ExposingWebServicesToAJAXTutorial.aspx" target="_blank">Web Services and Page Methods</a>. For the project I am working on, based on the design and flexibility for page developers, I use PageMethods to query data from the server side and it worked well. But there is one minor issue with PageMethods &#8211; you can&#8217;t assign Javascript inner functions for the success and error callbacks. It&#8217;s not a big deal, but I like the way that Google Map uses closures. So I searched for alternatives and I found <a href="http://jquery.com/" target="_blank">jQuery</a> has the <a href="http://docs.jquery.com/Ajax" target="_blank">ajax() function</a> which is what I need.</p>
<p>Here I build two pages &#8211; one uses PageMethods, another used jQuery &#8211; for comparison of the syntax and usage.</p>
<p>I use two basic container classes for my data passed between client and server:</p>
<div style="font-family:Courier New;font-size:9pt;color:black;background:white;">
<p style="margin:0;"><span style="color:blue;">using</span> System;</p>
<p style="margin:0;"><span style="color:blue;">namespace</span> Posts</p>
<p style="margin:0;">{</p>
<p style="padding-left:30px;margin:0;">[<span style="color:#2b91af;">Serializable</span>]</p>
<p style="padding-left:30px;margin:0;"><span style="color:blue;">public</span> <span style="color:blue;">class</span> <span style="color:#2b91af;">LatLong</span></p>
<p style="padding-left:30px;margin:0;">{</p>
<p style="padding-left:60px;margin:0;"><span style="color:blue;">public</span> <span style="color:blue;">double</span>? latitude;</p>
<p style="padding-left:60px;margin:0;"><span style="color:blue;">public</span> <span style="color:blue;">double</span>? longitude;</p>
<p style="padding-left:30px;margin:0;">}</p>
<p style="margin:0;">}</p>
<p style="margin:0;">
</div>
<div style="font-family:Courier New;font-size:9pt;color:black;background:white;">
<p style="margin:0;"><span style="color:blue;">using</span> System;</p>
<p style="margin:0;"><span style="color:blue;">namespace</span> Posts</p>
<p style="margin:0;">{</p>
<p style="padding-left:30px;margin:0;">[<span style="color:#2b91af;">Serializable</span>]</p>
<p style="padding-left:30px;margin:0;"><span style="color:blue;">public</span> <span style="color:blue;">class</span> <span style="color:#2b91af;">MapView</span></p>
<p style="padding-left:30px;margin:0;">{</p>
<p style="padding-left:60px;margin:0;"><span style="color:blue;">public</span> <span style="color:#2b91af;">LatLong</span> center;</p>
<p style="padding-left:60px;margin:0;"><span style="color:blue;">public</span> <span style="color:blue;">int</span>? zoom;</p>
<p style="padding-left:30px;margin:0;">}</p>
<p style="margin:0;">}</p>
<p style="margin:0;">
</div>
<p style="margin:0;">The MapViewData class provides a static method to generate random map view data:</p>
<p style="margin:0;">
<div style="background:white none repeat scroll 0 0;font-family:Courier New;font-size:9pt;color:black;">
<p style="margin:0;"><span style="color:blue;">using</span> System;</p>
<p style="margin:0;"><span style="color:blue;">using</span> System.Collections;</p>
<p style="margin:0;"><span style="color:blue;">using</span> System.Collections.Generic;</p>
<p style="margin:0;">
<p style="margin:0;"><span style="color:blue;">namespace</span> Posts</p>
<p style="margin:0;">{</p>
<p style="padding-left:30px;margin:0;"><span style="color:blue;">public</span> <span style="color:blue;">class</span> <span style="color:#2b91af;">MapViewData</span></p>
<p style="padding-left:30px;margin:0;">{</p>
<p style="padding-left:60px;margin:0;"><span style="color:blue;">public</span> <span style="color:blue;">const</span> <span style="color:blue;">double</span> DefaultLatitude = 49.266214d;</p>
<p style="padding-left:60px;margin:0;"><span style="color:blue;">public</span> <span style="color:blue;">const</span> <span style="color:blue;">double</span> DefaultLongitude = -122.998577d;</p>
<p style="padding-left:60px;margin:0;"><span style="color:blue;">public</span> <span style="color:blue;">const</span> <span style="color:blue;">int</span> DefaultZoom = 12;</p>
<p style="padding-left:60px;margin:0;">
<p style="padding-left:60px;margin:0;"><span style="color:blue;">public</span> <span style="color:blue;">static</span> <span style="color:#2b91af;">List</span>&lt;<span style="color:#2b91af;">MapView</span>&gt; GenerateMapViewData(<span style="color:blue;">int</span> count)</p>
<p style="padding-left:60px;margin:0;">{</p>
<p style="padding-left:90px;margin:0;"><span style="color:#2b91af;">List</span>&lt;<span style="color:#2b91af;">MapView</span>&gt; data = <span style="color:blue;">new</span> <span style="color:#2b91af;">List</span>&lt;<span style="color:#2b91af;">MapView</span>&gt;();</p>
<p style="padding-left:90px;margin:0;"><span style="color:#2b91af;">Random</span> rand = <span style="color:blue;">new</span> <span style="color:#2b91af;">Random</span>();</p>
<p style="padding-left:90px;margin:0;">
<p style="padding-left:90px;margin:0;"><span style="color:blue;">for</span> (<span style="color:blue;">int</span> i = 0; i &lt; count; i++)</p>
<p style="padding-left:90px;margin:0;">{</p>
<p style="padding-left:120px;margin:0;"><span style="color:blue;">double</span> delta = rand.NextDouble() * 0.001d;</p>
<p style="padding-left:120px;margin:0;"><span style="color:#2b91af;">LatLong</span> latlong = <span style="color:blue;">new</span> <span style="color:#2b91af;">LatLong</span>();</p>
<p style="padding-left:120px;margin:0;">latlong.latitude = DefaultLatitude + delta;</p>
<p style="padding-left:120px;margin:0;">latlong.longitude = DefaultLongitude + delta;</p>
<p style="padding-left:120px;margin:0;"><span style="color:#2b91af;">MapView</span> view = <span style="color:blue;">new</span> <span style="color:#2b91af;">MapView</span>();</p>
<p style="padding-left:120px;margin:0;">view.center = latlong;</p>
<p style="padding-left:120px;margin:0;">view.zoom = DefaultZoom;</p>
<p style="padding-left:120px;margin:0;">data.Add(view);</p>
<p style="padding-left:90px;margin:0;">}</p>
<p style="padding-left:90px;margin:0;">
<p style="padding-left:90px;margin:0;"><span style="color:blue;">return</span> (data);</p>
<p style="padding-left:60px;margin:0;">}</p>
<p style="padding-left:30px;margin:0;">}</p>
<p style="margin:0;">}</p>
<p style="margin:0;">
<p style="margin:0;">
</div>
<p>The following static page method is in both ASP.NET AJAX and jQuery pages for return a collection of MapView objects to Javascript:</p>
<div style="font-family:Courier New;font-size:9pt;color:black;background:white;">
<p style="margin:0;">[<span style="color:#2b91af;">WebMethod</span>]</p>
<p style="margin:0;"><span style="color:blue;">public</span> <span style="color:blue;">static</span> <span style="color:#2b91af;">List</span>&lt;<span style="color:#2b91af;">MapView</span>&gt; GetMapViewData(<span style="color:blue;">int</span> count)</p>
<p style="margin:0;">{</p>
<p style="padding-left:30px;margin:0;"><span style="color:blue;">return</span> (<span style="color:#2b91af;">MapViewData</span>.GenerateMapViewData(count));</p>
<p style="margin:0;">}</p>
</div>
<p>The first example is the ASP.NET AJAX with PageMethods. Couple things to notice:</p>
<ol>
<li>EnablePageMethods=&#8221;true&#8221; in the ScriptManger &#8211; to enable the static page methods in ASP.NET page can be called from Javascript.</li>
<li>In success_callback, the result is the collection of MapView objects. We can loop through the collection and access properties of each object.</li>
</ol>
<div style="font-family:Courier New;font-size:9pt;color:black;background:white;">
<p style="margin:0;"><span style="background:#ffee62;">&lt;%</span><span style="color:blue;">@</span> <span style="color:#a31515;">Page</span> <span style="color:red;">Language</span><span style="color:blue;">=&#8221;C#&#8221;</span> <span style="color:red;">AutoEventWireup</span><span style="color:blue;">=&#8221;true&#8221;</span> <span style="color:red;">CodeBehind</span><span style="color:blue;">=&#8221;Compare1.aspx.cs&#8221;</span> <span style="color:red;">Inherits</span><span style="color:blue;">=&#8221;Posts.Compare1&#8243;</span> <span style="background:#ffee62;">%&gt;</span></p>
<p style="margin:0;">
<p style="margin:0;"><span style="color:blue;">&lt;!</span><span style="color:#a31515;">DOCTYPE</span> <span style="color:red;">html</span> <span style="color:red;">PUBLIC</span> <span style="color:blue;">&#8220;-//W3C//DTD XHTML 1.0 Transitional//EN&#8221;</span> <span style="color:blue;">&#8220;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&#8221;&gt;</span></p>
<p style="margin:0;">
<p style="margin:0;"><span style="color:blue;">&lt;</span><span style="color:#a31515;">html</span> <span style="color:red;">xmlns</span><span style="color:blue;">=&#8221;http://www.w3.org/1999/xhtml&#8221;</span> <span style="color:blue;">&gt;</span></p>
<p style="margin:0;"><span style="color:blue;">&lt;</span><span style="color:#a31515;">head</span> <span style="color:red;">runat</span><span style="color:blue;">=&#8221;server&#8221;&gt;</span></p>
<p style="margin:0;"><span style="color:blue;">&lt;</span><span style="color:#a31515;">title</span><span style="color:blue;">&gt;</span>ASP.NET AJAX<span style="color:blue;">&lt;/</span><span style="color:#a31515;">title</span><span style="color:blue;">&gt;</span></p>
<p style="padding-left:30px;margin:0;"><span style="color:blue;">&lt;</span><span style="color:#a31515;">script</span> <span style="color:red;">type</span><span style="color:blue;">=&#8221;text/javascript&#8221;&gt;</span></p>
<p style="padding-left:30px;margin:0;"><span style="color:blue;">function</span> get_mapview_data(count)</p>
<p style="padding-left:30px;margin:0;">{</p>
<p style="padding-left:60px;margin:0;">PageMethods.GetMapViewData(</p>
<p style="padding-left:90px;margin:0;">count,</p>
<p style="padding-left:90px;margin:0;">success_callback,</p>
<p style="padding-left:90px;margin:0;">error_callback</p>
<p style="padding-left:60px;margin:0;">);</p>
<p style="padding-left:30px;margin:0;">}</p>
<p style="padding-left:30px;margin:0;">
<p style="padding-left:30px;margin:0;"><span style="color:blue;">function</span> success_callback(result, context, method)</p>
<p style="padding-left:30px;margin:0;">{</p>
<p style="padding-left:60px;margin:0;"><span style="color:blue;">var</span> sb = <span style="color:blue;">new</span> Sys.StringBuilder();</p>
<p style="padding-left:60px;margin:0;"><span style="color:blue;">for</span> (<span style="color:blue;">var</span> i <span style="color:blue;">in</span> result) {</p>
<p style="padding-left:90px;margin:0;">sb.append(<span style="color:#a31515;">&#8220;center -&gt; (&#8220;</span> + result[i].center.latitude + <span style="color:#a31515;">&#8220;, &#8220;</span> + result[i].center.longitude + <span style="color:#a31515;">&#8220;), &#8220;</span>);</p>
<p style="padding-left:90px;margin:0;">sb.append(<span style="color:#a31515;">&#8220;zoom -&gt; &#8220;</span> + result[i].zoom);</p>
<p style="padding-left:90px;margin:0;">sb.append(<span style="color:#a31515;">&#8220;&lt;br/&gt;&#8221;</span>);</p>
<p style="padding-left:60px;margin:0;">}</p>
<p style="padding-left:60px;margin:0;">$get(<span style="color:#a31515;">&#8220;mapview_data&#8221;</span>).innerHTML = sb.toString();</p>
<p style="padding-left:30px;margin:0;">}</p>
<p style="padding-left:30px;margin:0;">
<p style="padding-left:30px;margin:0;"><span style="color:blue;">function</span> error_callback(error, context, method)</p>
<p style="padding-left:30px;margin:0;">{</p>
<p style="padding-left:60px;margin:0;">$get(<span style="color:#a31515;">&#8220;mapview_data&#8221;</span>).innerHTML = <span style="color:#a31515;">&#8220;Error &#8211;&gt; &#8220;</span> + error.get_message();</p>
<p style="padding-left:30px;margin:0;">}</p>
<p style="padding-left:30px;margin:0;"><span style="color:blue;">&lt;/</span><span style="color:#a31515;">script</span><span style="color:blue;">&gt;</span></p>
<p style="margin:0;"><span style="color:blue;">&lt;/</span><span style="color:#a31515;">head</span><span style="color:blue;">&gt;</span></p>
<p style="margin:0;"><span style="color:blue;">&lt;</span><span style="color:#a31515;">body</span><span style="color:blue;">&gt;</span></p>
<p style="padding-left:30px;margin:0;"><span style="color:blue;">&lt;</span><span style="color:#a31515;">form</span> <span style="color:red;">id</span><span style="color:blue;">=&#8221;form1&#8243;</span> <span style="color:red;">runat</span><span style="color:blue;">=&#8221;server&#8221;&gt;</span></p>
<p style="padding-left:30px;margin:0;"><span style="color:blue;">&lt;</span><span style="color:#a31515;">asp</span><span style="color:blue;">:</span><span style="color:#a31515;">ScriptManager</span> <span style="color:red;">ID</span><span style="color:blue;">=&#8221;ScriptManager1&#8243;</span> <span style="color:red;">runat</span><span style="color:blue;">=&#8221;server&#8221;</span> <span style="color:red;">EnablePageMethods</span><span style="color:blue;">=&#8221;true&#8221;</span> <span style="color:blue;">/&gt;</span></p>
<p style="padding-left:30px;margin:0;"><span style="color:blue;">&lt;</span><span style="color:#a31515;">div</span><span style="color:blue;">&gt;</span></p>
<p style="padding-left:30px;margin:0;"><span style="color:blue;">&lt;</span><span style="color:#a31515;">a</span> <span style="color:red;">href</span><span style="color:blue;">=&#8221;javascript:get_mapview_data(20);&#8221;&gt;</span>Get MapView data<span style="color:blue;">&lt;/</span><span style="color:#a31515;">a</span><span style="color:blue;">&gt;</span></p>
<p style="padding-left:30px;margin:0;"><span style="color:blue;">&lt;/</span><span style="color:#a31515;">div</span><span style="color:blue;">&gt;</span></p>
<p style="padding-left:30px;margin:0;"><span style="color:blue;">&lt;</span><span style="color:#a31515;">br</span> <span style="color:blue;">/&gt;</span></p>
<p style="padding-left:30px;margin:0;"><span style="color:blue;">&lt;</span><span style="color:#a31515;">div</span> <span style="color:red;">id</span><span style="color:blue;">=&#8221;mapview_data&#8221;&gt;&lt;/</span><span style="color:#a31515;">div</span><span style="color:blue;">&gt;</span></p>
<p style="padding-left:30px;margin:0;"><span style="color:blue;">&lt;/</span><span style="color:#a31515;">form</span><span style="color:blue;">&gt;</span></p>
<p style="margin:0;"><span style="color:blue;">&lt;/</span><span style="color:#a31515;">body</span><span style="color:blue;">&gt;</span></p>
<p style="margin:0;"><span style="color:blue;">&lt;/</span><span style="color:#a31515;">html</span><span style="color:blue;">&gt;</span></p>
</div>
<p>The second example isjQuery with PageMethods. Couple things to notice too:</p>
<ol>
<li>The URL to request is the current page URL concatenated with &#8220;/PageMethodName&#8221;.</li>
<li>I use <a href="http://www.json.org/js.html" target="_blank">JSON2 Javascript library</a> to parse (deserialize) the XmlHttpRequest object returned in the error callback. You can use Sys.Serialization.JavaScriptSerializer.deserialize() to do the same thing here.</li>
<li>There is no need to use ScriptManager.</li>
</ol>
<div style="font-family:Courier New;font-size:9pt;color:black;background:white;">
<p style="margin:0;"><span style="background:#ffee62;">&lt;%</span><span style="color:blue;">@</span> <span style="color:#a31515;">Page</span> <span style="color:red;">Language</span><span style="color:blue;">=&#8221;C#&#8221;</span> <span style="color:red;">AutoEventWireup</span><span style="color:blue;">=&#8221;true&#8221;</span> <span style="color:red;">CodeBehind</span><span style="color:blue;">=&#8221;Compare2.aspx.cs&#8221;</span> <span style="color:red;">Inherits</span><span style="color:blue;">=&#8221;Posts.Compare2&#8243;</span> <span style="background:#ffee62;">%&gt;</span></p>
<p style="margin:0;">
<p style="margin:0;"><span style="color:blue;">&lt;!</span><span style="color:#a31515;">DOCTYPE</span> <span style="color:red;">html</span> <span style="color:red;">PUBLIC</span> <span style="color:blue;">&#8220;-//W3C//DTD XHTML 1.0 Transitional//EN&#8221;</span> <span style="color:blue;">&#8220;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&#8221;&gt;</span></p>
<p style="margin:0;">
<p style="margin:0;"><span style="color:blue;">&lt;</span><span style="color:#a31515;">html</span> <span style="color:red;">xmlns</span><span style="color:blue;">=&#8221;http://www.w3.org/1999/xhtml&#8221;</span> <span style="color:blue;">&gt;</span></p>
<p style="margin:0;"><span style="color:blue;">&lt;</span><span style="color:#a31515;">head</span> <span style="color:red;">runat</span><span style="color:blue;">=&#8221;server&#8221;&gt;</span></p>
<p style="padding-left:30px;margin:0;"><span style="color:blue;">&lt;</span><span style="color:#a31515;">title</span><span style="color:blue;">&gt;</span>jQuery<span style="color:blue;">&lt;/</span><span style="color:#a31515;">title</span><span style="color:blue;">&gt;</span></p>
<p style="padding-left:30px;margin:0;"><span style="color:blue;">&lt;</span><span style="color:#a31515;">script</span> <span style="color:red;">type</span><span style="color:blue;">=&#8221;text/javascript&#8221;</span> <span style="color:red;">src</span><span style="color:blue;">=&#8221;/JavaScript/jquery-1.2.6.min.js&#8221;&gt;&lt;/</span><span style="color:#a31515;">script</span><span style="color:blue;">&gt;</span></p>
<p style="padding-left:30px;margin:0;"><span style="color:blue;">&lt;</span><span style="color:#a31515;">script</span> <span style="color:red;">type</span><span style="color:blue;">=&#8221;text/javascript&#8221;</span> <span style="color:red;">src</span><span style="color:blue;">=&#8221;/JavaScript/json2.js&#8221;&gt;&lt;/</span><span style="color:#a31515;">script</span><span style="color:blue;">&gt;</span></p>
<p style="padding-left:30px;margin:0;"><span style="color:blue;">&lt;</span><span style="color:#a31515;">script</span> <span style="color:red;">type</span><span style="color:blue;">=&#8221;text/javascript&#8221;&gt;</span></p>
<p style="padding-left:30px;margin:0;"><span style="color:blue;">function</span> get_mapview_data(count)</p>
<p style="padding-left:30px;margin:0;">{</p>
<p style="padding-left:60px;margin:0;">$.ajax({</p>
<p style="padding-left:90px;margin:0;">type: <span style="color:#a31515;">&#8220;POST&#8221;</span>,</p>
<p style="padding-left:90px;margin:0;">url: window.location.href + <span style="color:#a31515;">&#8220;/GetMapViewData&#8221;</span>,</p>
<p style="padding-left:90px;margin:0;">data: <span style="color:#a31515;">&#8220;{\&#8221;count\&#8221;:\&#8221;"</span> + count + <span style="color:#a31515;">&#8220;\&#8221;}&#8221;</span>,</p>
<p style="padding-left:90px;margin:0;">contentType: <span style="color:#a31515;">&#8220;application/json; charset=utf-8&#8243;</span>,</p>
<p style="padding-left:90px;margin:0;">dataType: <span style="color:#a31515;">&#8220;json&#8221;</span>,</p>
<p style="padding-left:90px;margin:0;">success: <span style="color:blue;">function</span>(xhr, status) {</p>
<p style="padding-left:120px;margin:0;"><span style="color:blue;">var</span> sb = <span style="color:#a31515;">&#8220;&#8221;</span>;</p>
<p style="padding-left:120px;margin:0;"><span style="color:blue;">for</span> (<span style="color:blue;">var</span> i <span style="color:blue;">in</span> xhr) {</p>
<p style="padding-left:150px;margin:0;">sb += <span style="color:#a31515;">&#8220;center -&gt; (&#8220;</span> + xhr[i].center.latitude + <span style="color:#a31515;">&#8220;, &#8220;</span> + xhr[i].center.longitude + <span style="color:#a31515;">&#8220;), &#8220;</span>;</p>
<p style="padding-left:150px;margin:0;">sb += <span style="color:#a31515;">&#8220;zoom -&gt; &#8220;</span> + xhr[i].zoom;</p>
<p style="padding-left:150px;margin:0;">sb += <span style="color:#a31515;">&#8220;&lt;br/&gt;&#8221;</span>;</p>
<p style="padding-left:120px;margin:0;">}</p>
<p style="padding-left:120px;margin:0;">$(<span style="color:#a31515;">&#8220;#mapview_data&#8221;</span>).html(sb);</p>
<p style="padding-left:90px;margin:0;">},</p>
<p style="padding-left:90px;margin:0;">error: <span style="color:blue;">function</span>(xhr, status, error) {</p>
<p style="padding-left:120px;margin:0;"><span style="color:blue;">var</span> err = JSON.parse(xhr.responseText);</p>
<p style="padding-left:120px;margin:0;">$(<span style="color:#a31515;">&#8220;#mapview_data&#8221;</span>).html(<span style="color:#a31515;">&#8220;Error &#8211;&gt; &#8220;</span> + err.Message);</p>
<p style="padding-left:90px;margin:0;">}</p>
<p style="padding-left:60px;margin:0;">});</p>
<p style="padding-left:30px;margin:0;">}</p>
<p style="padding-left:30px;margin:0;"><span style="color:blue;">&lt;/</span><span style="color:#a31515;">script</span><span style="color:blue;">&gt;</span></p>
<p style="margin:0;"><span style="color:blue;">&lt;/</span><span style="color:#a31515;">head</span><span style="color:blue;">&gt;</span></p>
<p style="margin:0;"><span style="color:blue;">&lt;</span><span style="color:#a31515;">body</span><span style="color:blue;">&gt;</span></p>
<p style="padding-left:30px;margin:0;"><span style="color:blue;">&lt;</span><span style="color:#a31515;">form</span> <span style="color:red;">id</span><span style="color:blue;">=&#8221;form1&#8243;</span> <span style="color:red;">runat</span><span style="color:blue;">=&#8221;server&#8221;&gt;</span></p>
<p style="padding-left:30px;margin:0;"><span style="color:blue;">&lt;</span><span style="color:#a31515;">div</span><span style="color:blue;">&gt;</span></p>
<p style="padding-left:30px;margin:0;"><span style="color:blue;">&lt;</span><span style="color:#a31515;">a</span> <span style="color:red;">href</span><span style="color:blue;">=&#8221;javascript:get_mapview_data(20);&#8221;&gt;</span>Get MapView data<span style="color:blue;">&lt;/</span><span style="color:#a31515;">a</span><span style="color:blue;">&gt;</span></p>
<p style="padding-left:30px;margin:0;"><span style="color:blue;">&lt;/</span><span style="color:#a31515;">div</span><span style="color:blue;">&gt;</span></p>
<p style="padding-left:30px;margin:0;"><span style="color:blue;">&lt;</span><span style="color:#a31515;">br</span> <span style="color:blue;">/&gt;</span></p>
<p style="padding-left:30px;margin:0;"><span style="color:blue;">&lt;</span><span style="color:#a31515;">div</span> <span style="color:red;">id</span><span style="color:blue;">=&#8221;mapview_data&#8221;&gt;&lt;/</span><span style="color:#a31515;">div</span><span style="color:blue;">&gt;</span></p>
<p style="padding-left:30px;margin:0;"><span style="color:blue;">&lt;/</span><span style="color:#a31515;">form</span><span style="color:blue;">&gt;</span></p>
<p style="margin:0;"><span style="color:blue;">&lt;/</span><span style="color:#a31515;">body</span><span style="color:blue;">&gt;</span></p>
<p style="margin:0;"><span style="color:blue;">&lt;/</span><span style="color:#a31515;">html</span><span style="color:blue;">&gt;</span></p>
</div>
<p>I use Firebug to check the Post and Response in both XmlHttpRequests, they are the same in both pages.</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/atsung.wordpress.com/21/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/atsung.wordpress.com/21/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/atsung.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/atsung.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/atsung.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/atsung.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/atsung.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/atsung.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/atsung.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/atsung.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/atsung.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/atsung.wordpress.com/21/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=atsung.wordpress.com&blog=4439908&post=21&subd=atsung&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://atsung.wordpress.com/2008/08/12/jquery-and-aspnet-ajax-pagemethods/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7ec703e693a5641f5e97b6387daeb887?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">atsung</media:title>
		</media:content>
	</item>
	</channel>
</rss>