• Home
  • New Entries
  • Popular Entries
  • Submit a Story
  • About

Facebook AJAX, FBJS, Dialogue Self-Post ...

I was frustrated with the fbjs and mock ajax popups because i couldn't get a popup form to post repeatedly to itself.

I was frustrated with the fbjs and mock ajax popups because i couldn get a popup form to post repeatedly to itself. If you follow the documentation by the letter to add these popups, you will end up creating new dialogues and the user will have to close them all manually.

My forward dialogue script below will use AJAX to open a dialogue, then post the contents back to itself as many times as you like when you click Ok. The cancel button will close the dialogue when the user is done.

- In this case prams sho blank for the first post. You may change it if you want to post page info, but i just use a URL with a query string.
- url is the url of the page that you want to do the ajax post to.
- forwardForm is replaced by the id of the form on the page on your application that you are posting too.
- I am using 2 seperate methods so the first one doesn post anything and chew bandwidth.
- Also note the new Dialogue() is declared outside the function so it doesn create a new one every time. Saw lots of complaints about this on the wiki.


var dlg = new Dialog();
function do_forward(url)
{
    var ok = Forward;
    var cancel = Cancel;
    var ajax = new Ajax();

    ajax.responseType = Ajax.FBML;
    ajax.requireLogin = true;
    ajax.ondone = function(data)
    {
        dlg.showChoice(Forward listing, data, ok, cancel);
        dlg.onconfirm = function() {
            var fwdForm = document.getElementById(forwardForm);
            var newPrams = fwdForm.serialize();
            do_nextForward(url, newPrams);
            return false;
        }
    }
    ajax.post(url);
}

function do_nextForward(url, prams)
{
    var ok = Forward;
    var cancel = Cancel;
    var ajax = new Ajax();

    ajax.responseType = Ajax.FBML;
    ajax.requireLogin = true;
    ajax.ondone = function(data)
    {
        dlg.showChoice(Forward listing, data, ok, cancel);
        dlg.onconfirm = function() {
            var fwdForm = document.getElementById(forwardForm);
            var newPrams = fwdForm.serialize();
            do_nextForward(url, newPrams);
            return false;
        }
    }
    ajax.post(url, prams);
}


Notice that the dialogue is declared outside of the post function and is re-used. The Facebook Wiki examples all declare a new popup and will limit you to simple "Ok"/"Cancel" dialogues, but the above will enable functionality inside them.

The other not if you are using ASP.NET is that you will have to use Request[varName] to retrieve form post values. Facebook isn very .net friendly on canvas pages and even less friendly on the dialogues (not a whinge - I understand security concerns).

source: gatsdev.blogspot

 View Full Story.
Posted at 09:07:50 am | Permalink | Posted in Facebook  

Related Stuff

  • MooV: Using cutting edge Video phones and Software Video Phones - coupling all that with VoIP and empowering the disabled.

  • Moo Telecom: VoIP communications made easy - Ring anyway with the fun and ease of using a normal phone

  • TagR:Mobile Social Network with Real Time Locations Based services, and Ambience Intelligence, VoiP, IM, Skype, Googletalk, Mapping, Flickr, Events, Calendaring, Scheduling, SecondLife Support

  • ClearSMS : ClearSMS is a Web-based application that lets you send bulk SMS messages to your customers, contacts, or just about anyone.

  • Jajah:jah is a VoIP (Voice over IP) provider, founded by Austrians Roman Scharf and Daniel Mattes in 2005[1]. The Jajah headquarters are located in Mountain View, CA, USA, and Luxembourg. Jajah maintains a development centre in Israel.

  • Skype: It’s free to download and free to call other people on Skype. Skype the number one voice over ip software

  • PrivatePhone: a free local phone number with voicemail and messages you can check online or from any phone.

1 Comment |Add your comment.

Aslam Shahid said:

Its very nice for developers but it vl b more helpful it u plz provide screenshots of flow so new developers may learn soon..ThnX

Posted at September 27, 2008 05:40:46 am

Your Comment ...

  Name (required)

  Email (required, hidden)

  Website


Top Stuff

e-messenger

MessengerFX

eBuddy

ILoveIM

AIM Express

Top 20 Ruby CMS


Our Partners

Facebook Applications

Ajax Projects

Web 2.0 Sites

Webloglines

Human Development Handbook

Software Development Company

Ajaxlines

Stock Exchange Chat


About Ajaxlines

Ajaxlines is a project focused on providing its audience with a database of most of Ajax related articles, resources, tutorials and services from around the world.

Its purpose is to showcase the power of Ajax and to act as a portal to the Ajax development community.


Search


Topics

  • .Net (115)
  • Ajax (11)
  • Ajax Games (9)
  • Articles (94)
  • Bookmarking (35)
  • Calendar (19)
  • Chat (40)
  • ColdFusion (3)
  • CSS (48)
  • Email (23)
  • Facebook (41)
  • Flash (17)
  • Google (31)
  • Html (16)
  • Image (11)
  • International Calls & VOIP (7)
  • Java (40)
  • Javascript (190)
  • jQuery (3)
  • JSON (24)
  • Perl (2)
  • PHP (97)
  • Presentation (19)
  • Python (3)
  • Resources (2)
  • RSS (1)
  • Ruby (15)
  • Storage (4)
  • Toolkits (96)
  • Tutorials (203)
  • UI (12)
  • Utilities (173)
  • Web2.0 (18)
  • XmlHttpRequest (22)
  • YUI (4)

© 2006 www.ajaxlines.com. All Rights Reserved. Powered by IRange