外部サーバー呼び出し(makeRequest)

「外部サーバー呼び出し(makeRequest)」の編集履歴(バックアップ)一覧に戻る
外部サーバー呼び出し(makeRequest)」を以下のとおり復元します。
*通常のmakeRequest

**リクエストの送信(例は mixi とか)

 //URL 設定
 oid = person.id.replace("mixi.jp:","");
 var url = "http://example.com/model/add/"+oid+"/";
 var post_data = { nickname:person.nickname };
 //オプション設定 
 var params = {}; 
 params[gadgets.io.RequestParameters.METHOD] = gadgets.io.MethodType.POST;
 params[gadgets.io.RequestParameters.CONTENT_TYPE] = gadgets.io.ContentType.TEXT; 	
 params[gadgets.io.RequestParameters.POST_DATA] = gadgets.io.encodeValues(post_data);
 params[gadgets.io.RequestParameters.REFRESH_INTERVAL] = 0;
 
 //リクエスト 
 gadgets.io.makeRequest(url, response, params); 

**レスポンスの処理

 function response(obj){   
 
        var str = "";
        //結果を表示 
 	if(obj.data){ 
 		str += obj.text; 
 		$("#heardocument").html(str);
 	}else{ 
 		$("#heardocument").html('取得できませんでした');
 	}
 	
 }

*opensocial-jquery を使う場合

params[gadgets.io.RequestParameters.REFRESH_INTERVAL] = 0; に相当する指定方法はあるのか???

**使用できるデータタイプ

dataType を使って指定

text, html, xml, json, jsonp, script, feed, data のいずれかを指定。 

**JQury.ajax を使う場合

  $.ajax({
    type: 'post',
    url: 'http://example.com/data.json',
    data: { comment: 'Say Hello!' },
    dataType: 'json',
    success: function(data, status) {
      console.log(data, status);
    },
    error: function(xhr, status, e) {
      console.info(xhr, status, e);
    }
  });

**jQuery.post を使う場合

  $.post('http://example.com/data.json', { comment: 'Say Hello!' },
    function(data, status) {}, 'json');

この場合はエラーをハンドリングできない。

*参考リンク

-[[署名付きリクエストで外部サーバへデータを保存する - プログラマー、再起動中>http://d.hatena.ne.jp/naoto5959/20090515/1242368665]]

-[[Ajax - opensocial-jquery - jQuery.ajax のすべてのリクエストをガジェットサーバのプロキシに中継します。互換性を保持しつつ、クロスドメイン制約を開放します。 - Google Code>http://code.google.com/p/opensocial-jquery/wiki/Ajax]]

復元してよろしいですか?