鈍足ランナーのIT日記

走るのが好きな5流のITエンジニアのブログ。

趣味の範囲は広いけど、どれも中途半端なクソブロガー楽しめるWebアプリを作ってあっと言わせたい。サーバーサイドPerl(Mojolicious)、クライアントサイドVue.js。Arduinoにも触手を伸ばす予定。

jqueryのajaxのクエリパラメータでカンマをエンコードしない方法

JQUERYのAPIによると

jQuery.ajax( url [, settings ] )Returns: jqXHR 

settingsの説明によると

The data option can contain either a query string of the form key1=value1&key2=value2, or an object of the form {key1: 'value1', key2: 'value2'}. If the latter form is used, the data is converted into a query string using jQuery.param() before it is sent.

適当な訳

dataオプションは、クエリ文字列「key1=value1&key2=value2」または、form形式「key1: 'value1', key2: 'value2'}. 」のobjectを指定することができる。 後者の場合、jQuery.param()メソッドで文字列変換されてから送信される。

なるほど。こんな感じだろうか。

$.ajax(url,{dataType: jsonp, data: decodeURIComponent($.param(params))});