<form action="test.php" method="post">
<input type="text" name="pic[]" value="1">
<input type="text" name="pic[]" value="4">
<input type="text" name="pic[]" value="5">
<input type="text" name="pic[]" value="4">
<input type="text" name="pic[]" value="5">
<input type="text" name="pic[]" value="6">
<input type="submit" value="提交" />
</form>就像这样的。AJAX下面如何取呢?

解决方案 »

  1.   

    什么ajax获取?不太明白要干嘛。。~<script src="http://www.coding123.net/JS/jquery.js" type="text/javascript"></script>
    <form action="test.php" method="post">
    <input type="text" name="pic[]" value="1">
    <input type="text" name="pic[]" value="4">
    <input type="text" name="pic[]" value="5">
    <input type="text" name="pic[]" value="4">
    <input type="text" name="pic[]" value="5">
    <input type="text" name="pic[]" value="6">
    <input type="submit" value="提交" />
    </form>
    <script>
        $(function () {
            alert($.param($('input[name="pic[]"]')))
        });
    </script>
      

  2.   

    因为要取到这个值,然后交给PHP去处理。怎么才能做到呢?》
      

  3.   

    还可以循环遍历所有节点
    $("input[name='pic[]']").each(function(){
      alert($(this).val());
    })
      

  4.   


    jquery$("input[name='pic']").val();取得以,分隔的字符串
      

  5.   

    ajax发送的就是输出的键值对字符串,php应该直接$_POST["pic[]"]就获取到了吧。。如果是get提交用$_GET["pic[]"]
      

  6.   

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title></title>
        <script src="Scripts/jquery-1.4.1.js" type="text/javascript"></script>
        <script>
            $(function () {            $("#btnSubmit").live("click", function () {
                    var values = [];
                    $("input:[name='pic[]']").each(function () {
                        values.push($(this).val());
                    });
                    values = values.join(",");
                    $.ajax({
                        url: 'Default.aspx',
                        data: { pic: values },
                        success: function (data) {
                            //你的操作
                        }
                    });
                });        });
        </script>
    </head>
    <body>
        <form action="test.php" method="post">
        <input type="text" name="pic[]" value="1">
        <input type="text" name="pic[]" value="4">
        <input type="text" name="pic[]" value="5">
        <input type="text" name="pic[]" value="4">
        <input type="text" name="pic[]" value="5">
        <input type="text" name="pic[]" value="6">
        <input type="button" id="btnSubmit" value="提交" />
        </form>
    </body>
    </html>
      

  7.   

    楼主还没有说清楚逻辑过程,就单你的代码。点击按钮就直接提交了。ajax在哪?
      

  8.   

    不用这么复杂,用serialize()或者serializeArray() 
        $.ajax({
            type: "GET",
            url: "some.php",
            data: $("form").serialize(),
            success: function(msg){
            }
        });