0
追加パラメータを変数としてリターン機能を渡す:
function post_json(post_string, response_handler) {
//
// do logging and other things with post string
//
$.post(post_string,{},response_handler,'json');
}
私はその後、様々なページでは、この呼び出しを使用します:
をこれは完璧に動作function handler_generic(json) {
var success = json.success;
var success_verbiage = json.success_verbiage;
// do lots of stuff here
}
:
post_json(post_url, handler_generic);
handler_generic機能がこれです。
私は何をしたいことは、このような機能を持っている:
function handler_generic_with_extra(json, unique_id) {
var success = json.success;
var success_verbiage = json.success_verbiage;
// do lots of stuff here and now do it with the
// unique id
}
私はこれらが機能しないと考えました、そして、彼らはいけない:
post_json(appended_post_string, handler_generic_with_extra(the_unique_id));
post_json(appended_post_string, handler_generic_with_extra(json, the_unique_id));
これらを処理するために、新しいpost_json関数を作成せず場合は、これを達成するための方法はありますか?
私はあなただけの閉鎖機能 'post_json(appended_post_string、機能(JSON)にJSON引数に渡す必要があると思いthik {戻りhandler_generic_with_extra(JSON、the_unique_idを);} ); ' – paulitto
@paulitto、thanks :) – Tuco