クエリ文字列パラメーターを取得して、これを実行しようとしています:
var hello = unescape(helloQueryString);
そしてそれは戻ります:
this+is+the+string
それ以外の:
this is the string
%20 がそこにある場合はうまく機能しますが、それは + です。+記号がスペースに移動するようにこれらを適切にデコードする方法はありますか?
ありがとう。
クエリ文字列パラメーターを取得して、これを実行しようとしています:
var hello = unescape(helloQueryString);
そしてそれは戻ります:
this+is+the+string
それ以外の:
this is the string
%20 がそこにある場合はうまく機能しますが、それは + です。+記号がスペースに移動するようにこれらを適切にデコードする方法はありますか?
ありがとう。
decodeURIComponent
関数はデコードを正しく処理します。
decodeURIComponent("this%20is%20the%20string"); // "this is the string"
次の記事をご覧ください。
後にこの行を追加するとうまくいきます:
hello = hello.replace( '+', ' ' );