weixin_33725515 2015-01-21 22:07 采纳率: 0%
浏览 9

Ajax表单进度重定向

I have a form which I have been trying to get a progress bar to work on. This form is in joomla and I have managed to get a Ajax progress bar to show when a file is being uploaded. However the usual habit of the form is that when it has been submitted, it will go to item page the form is associated with and will give a confirmation on that page saying that yes it was saved.

However with this new Ajax progress bar, the bar gets to 100% and looking in firebug it shows that both the POST and GET were both successful but the problem is that the browser stays on the form page without the original redirect to the same GET url?

Some of the code is as follows:

    JHTML::_('behavior.mootools');
    JHTML::_('behavior.formvalidation');

    $document =& JFactory::getDocument();

    $document->addScript('components/com_component/assets/validate.js');
    $document->addScript('jquery-1.7.js');
    $document->addScript('jquery.form.js');
    $document->addScript('custom.js');

    <form action="index.php" method="post" name="nameForm" id="idForm" enctype="multipart/form-data" class="form-validate">
<input type="file" name="item_file" id="item_file"/></td>

Then in the custom.js

$(document).ready(function()
{

    $('#item_file').change(function(){
        $('#submit').removeAttr('disabled');
    });

    $('#submit').change(function(){
        $('#progress').removeClass('hide');
    });


    var options = {

    beforeSend: function()
    {
        $("#progress").show();
        //clear everything
        $("#bar").width('0%');
        $("#message").html("");
        $("#percent").html("0%");
    },

    uploadProgress: function(event, position, total, percentComplete)
    {
        $("#bar").width(percentComplete+'%');
        $("#percent").html(percentComplete+'%');

    },

    success: function()
    {
        $("#bar").width('100%');
        $("#percent").html('100%');

    },

    complete: function(response)
    {
        $("#message").html("<font color='green'>"+response.responseText+"</font>");
    },

    complete: function()
    {

    },

    error: function()
    {


    }

};

     $("#idForm").ajaxForm(options);
});

Is there anything I can add to the custom.js so that the default action or redirect will still take place when the upload progress bar is complete.

Thanks.

  • 写回答

2条回答 默认 最新

  • csdnceshi62 2015-01-21 22:27
    关注

    Change your on success call of Ajax to go to the destination page:

      success: function()
        {
            $("#bar").width('100%');
            $("#percent").html('100%');
            //Go to new page
            window.location.href= 'index.php';
    
        },
    
    评论

报告相同问题?

悬赏问题

  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么