Mock Ajax in Facebook

This example simply sends the variable specified in the text area to response.php and then displays the result from response.php in the facebook window without reloading the main page.

In this particular example response.php only returns the same variables but this will be the underlying structure for many facebook apps. To use this example place the below fbml into the small default fbml box when editing the application info.


<fb:subtitle>Simple FBML</fb:subtitle>
<form id='form'>
<div id="preview" style="border-style: solid; border-color: black;   border-width: 1px; padding: 5px;"></div>
<textarea name="data"></textarea>
<input type="submit" clickrewriteform='form'  clickrewriteurl="http://osmosoft-php.com/facebook/simple/response.php"  clickrewriteid="preview" value=" get response"/>
</form>

then response.php contains :

<?php
	echo $_POST['data'];
?>

for more info please see :

http://wiki.developers.facebook.com/index.php/Mock_ajax

Advertisements

3 thoughts on “Mock Ajax in Facebook

  1. somehow the code you have written does not appear completely.

    i am unable to link the missing parts…
    isn’t there supposed to be a “onclick” event specifier?

    or its just me

Comments are closed.