Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/435.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/89.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Ajax表单进度重定向_Javascript_Jquery_Ajax - Fatal编程技术网

Javascript Ajax表单进度重定向

Javascript Ajax表单进度重定向,javascript,jquery,ajax,Javascript,Jquery,Ajax,我有一个表格,我一直在试图得到一个进度条来工作。这个表单在joomla中,我已经获得了一个Ajax进度条来显示文件何时上传。然而,表单的通常习惯是,当表单提交后,它将转到与表单相关联的项目页面,并在该页面上确认已保存 然而,有了这个新的Ajax进度条,进度条达到了100%,在firebug中查看,它显示POST和GET都成功了,但问题是浏览器停留在表单页面上,没有原始重定向到相同的GET url 部分守则如下: JHTML::_('behavior.mootools'); JHT

我有一个表格,我一直在试图得到一个进度条来工作。这个表单在joomla中,我已经获得了一个Ajax进度条来显示文件何时上传。然而,表单的通常习惯是,当表单提交后,它将转到与表单相关联的项目页面,并在该页面上确认已保存

然而,有了这个新的Ajax进度条,进度条达到了100%,在firebug中查看,它显示POST和GET都成功了,但问题是浏览器停留在表单页面上,没有原始重定向到相同的GET url

部分守则如下:

    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>
然后在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);
});
是否有任何我可以添加到custom.js的内容,以便在上传进度条完成时仍能执行默认操作或重定向


谢谢。

更改Ajax成功呼叫,转到目标页面:

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

    },

我也有同样的问题,我已经解决了

100%有效

action=javascript:void0

以你的形式使用

window.location.href


在ajax的成功中发挥作用。

您使用了字体元素吗?是的,那么在成功之后你想重定向页面吗?因此,请在success或complete方法中设置window.location.href。谢谢,这样做确实会重定向到网站的根目录,而不是表单关联的项目页面。单击提交并完成进度后,firebug中会显示一个GET url。。例如,“index.php?option=com_component&view=item&id=38”这将是需要重定向到的url。这是怎么可能的呢..还想补充一点,url总是不同的,因为不同的项目和不同的表单,所以不像只放window.location.href='index.php?option=com_component&view=item&id=38'那么简单;将所需数据从服务器发送到客户端,以生成URL的查询参数。。所以它将是-成功的:functiondata{//基于来自服务器的数据对象中的数据构建重定向url};