0

我通过 jquery ajax 从每个函数发送数据来覆盖/写入文件时遇到问题。我认为我的 post.php 不正确可以帮助我使用此功能吗?

$('.mod').each(function(){  
  var id = $(this).attr('id');

    $.ajax({
            type: "POST",
            url: "post.php",    
            data: "divid="+id+"&length="+$('.mod').length+"&ok=1",
            success: function(msg){  }
    });
 });

    if($_POST['ok']==1){        
                $File ='index.php';
    $Handle = fopen($File, 'w');
    $length = $_POST['length'] ;
    fwrite($Handle, ''.$_POST['divid'].'<br>');
    fclose($Handle); 
}

问候弗兰克

4

1 回答 1

2

序列化数据并将其发送到 php,而不是执行每个函数

var ids = $("input[name='ids']").serializeArray();

像这样只需将数据放入一个变量并将其发布到 php ......不是整个表单详细信息只有复选框详细信息

于 2010-12-07T10:18:16.807 回答