Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
次のコードがあります
$.post( "/factory/set",{ key : value }, function(response) { }); }, "json" );
どこ
key = "foo" value = "bar"
しかし、サーバーは常に「キー」と「バー」を取得します。キーを文字列ではなく変数として設定する方法はありますか?
オブジェクトを作成します。
var data = {};
次に、プロパティを設定します。
data[key] = value;
次に、への呼び出しでオブジェクトを使用します$.post()。
$.post()
$.post( "/factory/set",data, function(response) { }, "json" );