Ajax でフォームポスト
(function($) { $.fn.ajaxPost = function(callback, options) { var default_options = { data_type: 'html', before_send: function() {}, error_handler: function() {} }; options = $.extend(default_options, options) return this.each(function(){ if(this.tagName.toLowerCase() != 'form') return; var f = $(this); var submit = f.find('button[@type="submit"], input[@type="submit"]') f.submit(function(e) { e.preventDefault(); $.ajax({ url: f.attr('action'), type: 'POST', data: f.serialize() + '&mode=ajax', dataType: options.data_type, beforeSend: function() { submit.attr('disabled', 'disabled') options.before_send(); }, success: callback, error: options.error_handler, complete: function(xhr, textStatus) { submit.removeAttr('disabled') } }); }); }); } })(jQuery)
使い方
<form action="/hoge" id="hoge"> ..... </form>
$('#hoge').ajaxPost(function(data, textStatus) { alert(data); });
追記 2009/2/12 22:50
修正。complete オプションがあったのね。
Zooomr 用 Autopagerize SITEINFO 書いた
フォトーク
{ "name": "Zooomr photalk", "data": { "pageElement": "//table[@id=\"timeline\"]", "url": "http://(jp|www).zooomr.com/*", "nextLink": "//table[@id=\"timeline\"]/following-sibling::h2[1]/a[last()]", "exampleUrl": "http://jp.zooomr.com/" } }
nextLink 修正 23:30
写真ページ
{ "name": "Zooomr photos", "data": { "pageElement": "//table[@id=\"SubNav\"]/following-sibling::table[1]/tbody[1]/tr[1]/td[1]/table[1]", "url": "http://(jp|www).zooomr.com/photos*", "nextLink": "//a[@class=\"Next\"]", "exampleUrl": "http://jp.zooomr.com/" } }
追記
wedata に登録しておいた。