formプラグインでpostしてxmlでレスポンス受ける
responseのxmlは前の記事。
<form id="twitForm" action="twitter.cgi" method="post"> <input type="text" name="message" id="message" value="" size="80" /> <input type="submit" value="Twit!" /> </form>
$(document).ready(function() { var opt = { dataType: 'xml', success: onSuccess }; $('#twitForm').ajaxForm(opt); }); function onSuccess(res, res_stat){ if(res_stat != "success"){ alert("エラーが起きてる"); return; } var message = $('message', res).text(); var stat = $('status', res).text(); if(stat == "success"){ top.location.href = top.location.href; // リロードさせる } }