Post data with jquery ajax and overwrite/write file in external file
I have a problem with overwriting/writing file by sending data from an each function through jquery ajax. I think my post.php isn't correct can some help me with this feature?
$('.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>');
fcl开发者_JAVA百科ose($Handle);
}
Regards Frank
serialize the data and send it to the php rather than doing each function
var ids = $("input[name='ids']").serializeArray();
like this just take the data into a variable and post it to php... not the whole form details only checkbox details
精彩评论