douxie3625 2013-12-11 16:02
浏览 49
已采纳

JSON通过表单发送数据

I bought the uploadifive script and want to change some things. I've added a textfield called "name" and a textfield called "about".

The basic script that comes with Uploadifive is:

the form:

    <form action="<?php echo $domein.'/uploadstap2.php'; ?>" method="post" name="THEFORM">
    <input name="naam" type="text">
    <div id="queue"></div>
    <input id="file_upload" name="file_upload" type="file" multiple>
    <a style="position: relative; top: 8px;" href="javascript:$('#file_upload').uploadifive('upload')">Upload Files</a>
</form>

The script:

<script type="text/javascript">
    <?php $timestamp = time();?>
    $(function() {
        $('#file_upload').uploadifive({
            'auto'             : false,
            'checkScript'      : 'check-exists.php',
            'queueID'          : 'queue',
            'uploadScript'     : 'uploadifive.php',
            'onUploadComplete' : function(file, data) { console.log(data); }
        });
    });
</script>

The creaters wrote the following on there webppage:

A JSON object containing additional data to send to the server-side upload script. Data sent via this option will be sent via the headers and can be accessed via the $_POST array (if using the ‘post’ method). So if you send something like {‘someKey’ : ‘someValue’}, then you can access it as $_POST['someKey'].

Dus, ik kan dit doen:

<script type="text/javascript">
    <?php $timestamp = time();?>
    $(function() {
        $('#file_upload').uploadifive({
            'auto'             : false,
            'checkScript'      : 'check-exists.php',
            'formData'         : {'someKey' : 'someValue'},   !!!!!!! <<<< this is what i just added >>>>!!!!!
            'queueID'          : 'queue',
            'uploadScript'     : 'uploadifive.php',
            'onUploadComplete' : function(file, data) { console.log(data); }
        });
    });
</script>

But i need the value that people enter in "name" and "about" to be send on uploadComplete. How can i send this values in stead of: {'someKey' : 'someValue'}

Can somebody help me?

  • 写回答

2条回答 默认 最新

  • douwuying4709 2013-12-11 16:23
    关注

    You can try $('input[name=something]').val() (where something is the name of your input) to get the value of the textbox by checking the name of the element. You can use like this for your example

    'formData' :{name:$('input[name=name]').val(),about:$('input[name=about]').val()}

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥20 机器学习能否像多层线性模型一样处理嵌套数据
  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效