第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機(jī)立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

JavaScript / jQuery中的$ .param()逆函數(shù)

JavaScript / jQuery中的$ .param()逆函數(shù)

慕桂英546537 2019-10-18 14:47:46
給出以下形式:<form>    <input name="foo" value="bar">    <input name="hello" value="hello world"></form>我可以使用$.param( .. )構(gòu)造序列化表格:$.param( $('form input') )=> foo=bar&hello=hello+world如何使用JavaScript反序列化上面的String并返回哈希值?例如,$.magicFunction("foo=bar&hello=hello+world")=> {'foo' : 'bar', 'hello' : 'hello world'}參考:jQuery.param( obj )。
查看完整描述

3 回答

?
肥皂起泡泡

TA貢獻(xiàn)1829條經(jīng)驗(yàn) 獲得超6個贊

您應(yīng)該使用jQuery BBQ的deparam函數(shù)。經(jīng)過了充分的測試和記錄。


查看完整回答
反對 回復(fù) 2019-10-18
?
慕后森

TA貢獻(xiàn)1802條經(jīng)驗(yàn) 獲得超5個贊

這種簡短的功能方法怎么樣?


function parseParams(str) {

    return str.split('&').reduce(function (params, param) {

        var paramSplit = param.split('=').map(function (value) {

            return decodeURIComponent(value.replace(/\+/g, ' '));

        });

        params[paramSplit[0]] = paramSplit[1];

        return params;

    }, {});

}

例:


parseParams("this=is&just=an&example") // Object {this: "is", just: "an", example: undefined}



查看完整回答
反對 回復(fù) 2019-10-18
  • 3 回答
  • 0 關(guān)注
  • 952 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號