prevent重定向上提交形成 [英] prevent redirection on submit to form

查看:102
本文介绍了prevent重定向上提交形成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下的code我使用提交我的表单处理脚本。表单被提交,但我得到重定向到从服务器的响应HTML。我想留在同一页上,并运行成功里面的回调函数:

响应头被发送 位置:http://url-I-am-Redirected-to-and-don't-want-to-be.html

我正在与第三方,并已超过服务器端code我提交到无法控制的。

  $('#去)。点击(函数(){

        $阿贾克斯({
        键入:POST,
        数据:$('#简报的形式')序列化()。
        网址:$('#通讯)ATTR(行动),
        成功:函数(){
        $('#image_container)。隐藏(1000,

       );
      }
     });

    }
 

解决方案

在点击块的末尾添加

 返回false
 

I have the following code I am using to submit my form to a processing script. the form gets submitted but I am getting redirected to the response html from the server. I want to stay on the same page and run the callback function inside success:

the response header is sending location:http://url-I-am-Redirected-to-and-don't-want-to-be.html

I am working with third party and have no control over the server side code I am submitting to.

  $('#go').click (function () {

        $.ajax ( {
        type: 'POST',   
        data: $('#newsletter form').serialize(),
        url: $('#newsletter').attr('action'),
        success: function(){
        $('#image_container').hide (1000,

       );
      }
     });

    }

解决方案

At the end of the click block add

return false

这篇关于prevent重定向上提交形成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆