开发者

$.post variable as array with values?

开发者 https://www.devze.com 2023-01-08 16:10 出处:网络
sending some data via post but want to send an array to but keep getting errors? excludes is the array i\'m trying to send.

sending some data via post but want to send an array to but keep getting errors?

excludes is the array i'm trying to send.

        $.post("/youradmin_v2/scripts/php/process.php", { 
            funcName:'searchContent',
            table:'content', 
            fields:'title,contentID', 
            keyword:$(this).val(), 
            tag:'option',
         开发者_StackOverflow社区   excludes: ['contentType'=>'client','contentType'=>'mainsetion']                 
            }, 
            function(data){
            $("#filterContentMenu").html(data);
        });

I can't seem to find the correct way to format the array for posting?

or to clarify what i want is to turn this into a php array like

$excludes=array('fieldA'=>'client','feildB'=>'mainsetion')   

to be used like

foreach($excludes as $value) {
        $toExclude .=" AND ".$value['name']."!='".$value['value']."' ".$value;
    }


    $.post("/youradmin_v2/scripts/php/process.php", { 
         funcName:'searchContent',
         table:'content', 
         fields:'title,contentID', 
         keyword:'blah', 
         tag:'option',
         excludes: {contentType:'client',anotherContentType:'mainsetion'}              
        }, 
        function(data){
        $("#filterContentMenu").html(data);
    });


You seem to be using PHP-style notation to specify the array keys. Try

excludes: {'contentType':['client','mainsetion']}   
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号