- Note that url must be full, absolute path to file on your server — not a canvas page (apps.facebook…).
- One you should note that there is no “setInnerHtml” call in FBJS for security reasons. If you want to add dynamic HTML you must add it on the server side and pass it using the setInnerFBML call. (Beta. You can now use setInnerXHTML to pass HTML back from Ajax calls. You can also use FBJS_LocalProxy to bypass the Facebook server hop.)
- Don’t pass HTML with
setTextValuebecause it won’t work. - Ajax has an apparent short ~10 second max timeout! –Does anyone have an alternative for queries that may take longer for some users?
- Be aware of silent 5000 byte size limit to JSON replies if JSON is not perfect (use json_encode to avoid this bug) http://bugs.developers.facebook.com/show_bug.cgi?id=363
- Ideally the url will point to a non-static location that has content sent through some form of CGI. In formal language, the url must respond to a request for application/x-www-form-urlencoded content.
- When using JSON and setInnerFBML, the prefix of the FBML parameter has to be ‘fbml_’. The parameter will then be sanitised, and passed on to setInnerFBML.
These
links demonstrate the Ajax object:<br />
<a href=”#” onclick=”do_ajax(Ajax.JSON); return
false;”>JSON</a><br />
<a href=”#” onclick=”do_ajax(Ajax.RAW); return
false;”>RAW</a><br />
<a href=”#” onclick=”do_ajax(Ajax.FBML); return
false;”>FBML</a><br />
<label><input type=”checkbox” id=”requirelogin”
checked=”checked” /><span>Require
Login?</span></label><br />
<div><span id=”ajax1″></span><span
id=”ajax2″></span></div>
<script><!–
function do_ajax(type) { var ajax = new Ajax(); ajax.responseType =
type; switch (type) { case Ajax.JSON: ajax.ondone = function(data) {
document.getElementById(’ajax1′).setTextValue(data.message + ‘ The
current time is: ‘ + data.time + ‘. ‘);
document.getElementById(’ajax2′).setInnerFBML(data.fbml_test); } break;
case Ajax.FBML: ajax.ondone = function(data) {
document.getElementById(’ajax1′).setInnerFBML(data);
document.getElementById(’ajax2′).setTextValue(”); } break; case
Ajax.RAW: ajax.ondone = function(data) {
document.getElementById(’ajax1′).setTextValue(data);
document.getElementById(’ajax2′).setTextValue(”); } break; }
ajax.requireLogin =
document.getElementById(’requirelogin’).getChecked();
ajax.post(’http://example.com/testajax.php?t=’+type);
}
//–></script>
links demonstrate the Ajax object:<br />
<a href=”#” onclick=”do_ajax(Ajax.JSON); return
false;”>JSON</a><br />
<a href=”#” onclick=”do_ajax(Ajax.RAW); return
false;”>RAW</a><br />
<a href=”#” onclick=”do_ajax(Ajax.FBML); return
false;”>FBML</a><br />
<label><input type=”checkbox” id=”requirelogin”
checked=”checked” /><span>Require
Login?</span></label><br />
<div><span id=”ajax1″></span><span
id=”ajax2″></span></div>
<script><!–
function do_ajax(type) { var ajax = new Ajax(); ajax.responseType =
type; switch (type) { case Ajax.JSON: ajax.ondone = function(data) {
document.getElementById(’ajax1′).setTextValue(data.message + ‘ The
current time is: ‘ + data.time + ‘. ‘);
document.getElementById(’ajax2′).setInnerFBML(data.fbml_test); } break;
case Ajax.FBML: ajax.ondone = function(data) {
document.getElementById(’ajax1′).setInnerFBML(data);
document.getElementById(’ajax2′).setTextValue(”); } break; case
Ajax.RAW: ajax.ondone = function(data) {
document.getElementById(’ajax1′).setTextValue(data);
document.getElementById(’ajax2′).setTextValue(”); } break; }
ajax.requireLogin =
document.getElementById(’requirelogin’).getChecked();
ajax.post(’http://example.com/testajax.php?t=’+type);
}
//–></script>
Entries (RSS)
интересно читать такие вещи. Спасибо большое….
повод задуматься….
Спасибо, хорошая статья. Подписался.
Админю сайты:
Все музыкальные новинки – скачать техно
Лучшее кино – лучшее кино
Самый новый софт – программы бесплатно
Строительство недвижимости – загородные коттеджи
Всё о автомобилях – машины и обзоры
Обзоры ноутбуков – блог о ноутбуках
Загородная недвижимость – ремонтируем авто
Полностью согласен. Автору респекыт!!!
Админю сайты:
Для автомобилистов – всё по авторемонту
Пивной блог – всё о пиве
Деньги – вебмани клуб
Гидроизоляция – гидроизоляция подвала
Мобильный портал – скачать java приложения
Бизнес-портал – портал о бизнесе
Кажется, это подойдет.
Нормально, можно cделать маленький сборник.
Всем Доброго утра! Вот это меня улыбнуло!!!!
Попробую, попозже отпишусь.
Интересно, я попробую.
Хорошая масль, вообще молодцы!
Последний абзац в тему!
Goodday
awesome post - i’m creating video about it and i will post it to youtube !
if you wana to help or just need a link send me email !
lol a few of the opinions most people distribute are just absurd, alot of times i ponder whether they honestly read the documents and content before leaving a comment or if perhaps they actually skim the title of the post and jot down the very first idea that comes to mind. nonetheless, it really is relaxing to read through smart commentary once in a while compared to the same exact, classic blog vomit that i mainly observe on the net i’m going to enjoy a few hands of facebook poker cheers
Buy:Benicar.Ventolin.Prozac.Female Cialis.Buspar.Female Pink Viagra.SleepWell.Lipothin.Advair.Seroquel.Acomplia.Wellbutrin SR.Cozaar.Lipitor.Zocor.Lasix.Nymphomax.Aricept.Zetia.Amoxicillin….
Buy:Actos.Lumigan.Prednisolone.Zovirax.Retin-A.Petcam (Metacam) Oral Suspension.Zyban.Nexium.Arimidex.Mega Hoodia.Accutane.Synthroid.Prevacid.Valtrex.Human Growth Hormone.100% Pure Okinawan Coral Calcium….