0

Here's the most basic code of it (i'm using this)

$("form").relatedSelects({
        onChangeLoad: 'datasupplier.php',
        selects: ['stateID', 'countyID', 'townID', 'villageID']
    });

i need to pass several more parameter for some reason. my usual ajax code is something like this

$.post("ajax/template.php", {myparams: $("#myparams").val(), action: "SEARCH_MEMBER_DETAILS" },
                    function (data){
                        var returnCode = data.returnCode;
                        if (returnCode == "1"){
                            $("#data").val(data.name);
                        }

                },"json");

question is, how do I send the params like myparams and action to the jQuery Related Selects code?

i tried something like

 $("form").relatedSelects({
            onChangeLoad: 'datasupplier.php',
                data: {action: "SEARCH_MEMBER_DETAILS"},
            selects: ['stateID', 'countyID', 'townID', 'villageID']
        });

but it seems the additional params are not sent

4

2 に答える 2

1

relatedScripts プラグインには、ajax リクエストを操作する機能はありません。

ただし、要件を達成するために少し変更することは可能です。

プラグインを変更する準備ができている場合は、次の手順を実行します

populate($caller,$select,o)プラグインのメソッドで、次の変更を行います

beforeSend: function(){
    return o.onLoadingStart.apply($select, Array.prototype.slice.call(arguments,0));
},

今ですbeforeSend: function(){ o.onLoadingStart.call($select); },

次に、スクリプトを次のように変更します

$("#example-2").relatedSelects({
    onChangeLoad : 'datasupplier.php',
    loadingMessage : 'Please wait',
    selects : ['stateID', 'countyID', 'townID', 'villageID'],
    onLoadingStart : function(jqxhr, settings) {
        console.log('st', arguments, settings.url);
        settings.url += '&t=tttt'
    }
});

デモ:フィドル

于 2013-03-07T08:56:49.223 に答える
0

プラグインのドキュメントを確認しましたが、必要なものを実現する方法がないようです。

プラグインを拡張して自分で機能を実装したくない場合は、onChangeLoad 内にパラメーターを作成して、次のように GET パラメーターとして渡すことを試すことができます。

$("form").relatedSelects({
        onChangeLoad: 'datasupplier.php?myparams='+$("myparams").val()+'&action=SEARCH_MEMBER_DETAILS',
       selects: ['stateID', 'countyID', 'townID', 'villageID']

});
于 2013-03-07T08:26:50.503 に答える