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

<channel>
	<title>Facebook Cookbook &#187; ajax</title>
	<atom:link href="http://fbcookbook.ofhas.in/tag/ajax/feed/" rel="self" type="application/rss+xml" />
	<link>http://fbcookbook.ofhas.in</link>
	<description>thousands of app development recipes</description>
	<lastBuildDate>Sun, 21 Mar 2010 10:38:11 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>dealing with ajax  on FBConnect</title>
		<link>http://fbcookbook.ofhas.in/2009/02/11/dealing-with-ajax-on-fbconnect/</link>
		<comments>http://fbcookbook.ofhas.in/2009/02/11/dealing-with-ajax-on-fbconnect/#comments</comments>
		<pubDate>Wed, 11 Feb 2009 11:21:29 +0000</pubDate>
		<dc:creator>Saidur Rahman</dc:creator>
				<category><![CDATA[FB Connect]]></category>
		<category><![CDATA[FBJS]]></category>
		<category><![CDATA[ajax]]></category>

		<guid isPermaLink="false">http://fbcookbook.ofhas.in/?p=209</guid>
		<description><![CDATA[<div style="float: right; width: 42px; padding-right: 10px; margin: 0 0 0 10px;"><script type="text/javascript">
<!--
digg_url = 'http://fbcookbook.ofhas.in/2009/02/11/dealing-with-ajax-on-fbconnect/';
digg_bgcolor = '#FFFFFF';
digg_skin = '';
digg_window = '';
digg_title = 'dealing with ajax  on FBConnect';
digg_bodytext = '';
digg_media = 'news';
digg_topic = '';
//-->
</script>
<script src="http://digg.com/tools/diggthis.js" type="text/javascript"></script>
</div>
  problem : 
need to store users information by ajax call while on connect . but face problems using fbjs ajax calls using on connect .some times face the problem to send ajax request  in the forum also get related type of problems . like:
http://forum.developers.facebook.com/viewtopic.php?id=28153
http://forum.developers.facebook.com/search.php?search_id=92171720
let’s see a quick solution by a common example.
solution:
here we [...]]]></description>
			<content:encoded><![CDATA[<div style="float: right; width: 42px; padding-right: 10px; margin: 0 0 0 10px;"><script type="text/javascript">
<!--
digg_url = 'http://fbcookbook.ofhas.in/2009/02/11/dealing-with-ajax-on-fbconnect/';
digg_bgcolor = '#FFFFFF';
digg_skin = '';
digg_window = '';
digg_title = 'dealing with ajax  on FBConnect';
digg_bodytext = '';
digg_media = 'news';
digg_topic = '';
//-->
</script>
<script src="http://digg.com/tools/diggthis.js" type="text/javascript"></script>
</div>
<p><!--[if gte mso 9]><xml> <w:WordDocument> <w:View>Normal</w:View> <w:Zoom>0</w:Zoom> <w:PunctuationKerning /> <w:ValidateAgainstSchemas /> <w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid> <w:IgnoreMixedContent>false</w:IgnoreMixedContent> <w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText> <w:Compatibility> <w:BreakWrappedTables /> <w:SnapToGridInCell /> <w:WrapTextWithPunct /> <w:UseAsianBreakRules /> <w:DontGrowAutofit /> </w:Compatibility> <w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel> </w:WordDocument> </xml><![endif]--><!--[if gte mso 9]><xml> <w:LatentStyles DefLockedState="false" LatentStyleCount="156"> </w:LatentStyles> </xml><![endif]--><!--[if !mso]><span class="mceItemObject"   classid="clsid:38481807-CA0E-42D2-BF39-B33AF135CC4D" id=ieooui></span> <mce:style><!  st1\:*{behavior:url(#ieooui) } --> <!--[endif]--><!--  /* Style Definitions */  p.MsoNormal, li.MsoNormal, div.MsoNormal 	{mso-style-parent:""; 	margin:0in; 	margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	font-size:12.0pt; 	font-family:"Times New Roman"; 	mso-fareast-font-family:"Times New Roman"; 	mso-bidi-font-family:"Times New Roman"; 	mso-bidi-language:AR-SA;} a:link, span.MsoHyperlink 	{color:blue; 	text-decoration:underline; 	text-underline:single;} a:visited, span.MsoHyperlinkFollowed 	{color:purple; 	text-decoration:underline; 	text-underline:single;} @page Section1 	{size:8.5in 11.0in; 	margin:1.0in 1.25in 1.0in 1.25in; 	mso-header-margin:.5in; 	mso-footer-margin:.5in; 	mso-paper-source:0;} div.Section1 	{page:Section1;} --><!--[if gte mso 10]> <mce:style><!   /* Style Definitions */  table.MsoNormalTable 	{mso-style-name:"Table Normal"; 	mso-tstyle-rowband-size:0; 	mso-tstyle-colband-size:0; 	mso-style-noshow:yes; 	mso-style-parent:""; 	mso-padding-alt:0in 5.4pt 0in 5.4pt; 	mso-para-margin:0in; 	mso-para-margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	font-size:10.0pt; 	font-family:"Times New Roman"; 	mso-ansi-language:#0400; 	mso-fareast-language:#0400; 	mso-bidi-language:#0400;} --> <!--[endif]--><strong>problem : </strong><br />
need to store users information by ajax call while on connect . but face problems using fbjs ajax calls using on connect .some times face the problem to send ajax request  in the forum also get related type of problems . like:</p>
<p><a href="http://forum.developers.facebook.com/viewtopic.php?id=28153">http://forum.developers.facebook.com/viewtopic.php?id=28153</a><br />
<a href="http://forum.developers.facebook.com/search.php?search_id=92171720">http://forum.developers.facebook.com/search.php?search_id=92171720</a></p>
<p>let’s see a quick solution by a common example.</p>
<p><strong>solution:</strong></p>
<p>here we look at the after connect get user profile picture and name by connect.</p>
<p>we create a script connect.php and include the  config  file .connect.php</p>
<pre name="code" class="php">

&lt;?php
/*
* include config file
*/
?&gt;

&lt;div id=&quot;user&quot;&gt; &lt;/div&gt;
&lt;fb:login-button onlogin=&quot;update_user_box();&quot;&gt;&lt;/fb:login-button&gt;
&lt;script type=&quot;text/javascript&quot;&gt;FB.init(&quot;key&quot;, &quot;xd_receiver.php&quot;); &lt;/script&gt;&lt;span style=&quot;display: block; padding-left: 6em;&quot;&gt;&lt;span&gt;
</pre>
<p>now it&#8217;s look like that:</p>
<p><img class="alignnone size-full wp-image-210" title="fb_conn_ajax" src="http://fbcookbook.ofhas.in/wp-content/uploads/2009/02/fb_conn_ajax.jpg" alt="fb_conn_ajax" /><br />
here in the connect button add onlogin function update_user_box().while click on connect then this function will call and update user by profile picture and name in the user id div.</p>
<p>in that update_user_box() function we will get the profile picture and name by calling ajax. So later on we can do anything by ajax.to call the ajax we will do it by jquery. Here I cannot do it by the fbjs  ajax method. For that reason I add jquery and other scripts.</p>
<pre name="code" class="php">

&lt;script src=&quot;http://ajax.googleapis.com/ajax/libs/jquery/1.3.1/jquery.min.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
&lt;script src=&quot;http://static.ak.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
</pre>
<p>now update update_user_box</p>
<pre name="code" class="php">

&lt;script type=&quot;text/javascript&quot;&gt;
function update_user_box()

{

Var url = “http://www.t...com.display.php”; // ajax url which is here display.php

$.ajax({
type: &quot;POST&quot;,
url:url,
data: &quot;save=yes&quot;,
success: function(msg){
var user_box = document.getElementById(&quot;user&quot;);
user_box.innerHTML =msg;

}
});
}
</pre>
<p>now create the display.php Which call by ajax.</p>
<p>In the display php also include config file which include facebook client library</p>
<p>here is code</p>
<pre name="code" class="php">
&lt;?php
define(MAIN_PATH, realpath(&#039;.&#039;));
include_once MAIN_PATH.&#039;/init.php&#039;;
$fb_uid = facebook_client()-&gt;get_loggedin_user();
echo &#039;&lt;span&gt; &lt;fb:profile-pic uid=&#039;.$fb_uid.&#039; facebook-logo=true&gt;&lt;/fb:profile-pic&gt; Welcome, &lt;fb:name uid=&#039;.$fb_uid.&#039; useyou=false&gt;&lt;/fb:name&gt;. You are signed in with your Facebook account.&lt;/span&gt;&#039;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;

?&gt;
&lt;span style=&quot;display: block; padding-left: 6em;&quot;&gt;&lt;span&gt;
</pre>
<p>this display.php returns the user profile picture and name. and it&#8217;s look like that.</p>
<p><img class="alignnone size-full wp-image-220" title="fb_conn_ajax3" src="http://fbcookbook.ofhas.in/wp-content/uploads/2009/02/fb_conn_ajax3.jpg" alt="fb_conn_ajax3" width="387" height="104" /></p>
<p>that&#8217;s it <img src='http://fbcookbook.ofhas.in/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://fbcookbook.ofhas.in/2009/02/11/dealing-with-ajax-on-fbconnect/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
