简体   繁体   English

如何将php POST参数传递到.load()php文件中

[英]how to pass php POST parameters into .load() php file

my code 我的代码

jquery jQuery的

<script type="text/javascript">
$(document).ready(function() {
$('.up').click(function() {
$('#postbox').load("uploader.php" );
    return false;

        });
        });

html HTML

<form enctype="multipart/form-data" action="uploader.php" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="100000" />
Wybierz plik: <input name="uploadedfile" type="file" /><br />
<input type="submit" value="Wyślij" class="up"/>
</form>

<INPUT TYPE = "Text" VALUE ="długość" NAME = "długość"><INPUT TYPE = "Text" VALUE           ="wysokość" NAME = "wysokość">
<INPUT TYPE = "Text" VALUE ="jakość [1-12]" NAME = "długość">


<div id="postbox">
</div>

now, my uploader.php file opens in #postbox, but i need to add parameters too 现在,我的uploader.php文件在#postbox中打开,但我也需要添加参数

I just need php file uploader.php to display in #postbox div, after form parameters are passed to it. 我只需要将php文件uploader.php显示在#postbox div中,然后将表单参数传递给它。 Now it displays "error while uploading the file", because it doesnt get file to upload. 现在它显示“上传文件时出错”,因为它没有上传文件。

.load allows you to send data as the second argument. .load允许您将数据作为第二个参数发送。

$('.up').click(function(e) {

    $postbox = $('#postbox'); 
    if( $postbox.find('form').length === 0 )
        $postbox.load('uploader.php');
    else 
    {
        var form_values = {};  
        $.each($postbox.serializeArray(), function(i,v){ form_values[ v.name ] = v.value  })
        $postbox.load('uploader.php', form_values ); 
    }
  e.preventDefault(); 
})

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM