如何停止的形式submittion后重定向? [英] How do I stop redirection after form submittion?

查看:709
本文介绍了如何停止的形式submittion后重定向?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在这里发表几个小时前,一个类似的问题,刚才我,我应该考虑使用AJAX来做到这一点的答案。因为我想完成这部分站点今天我买不起学习AJAX的基础知识,现​​在要做到这一点。这应该不是什么困难的,我thougt,我将能够做到这一点,但我没有足够的技术......

我有一个表格,当你点击提交,就张贴到twitter.com/statuses/update.xml~~V,我需要能够做到这一点,而不被重定向那里。

有没有一种简单的方法来做到这一点还是做我需要学习AJAX?

心存感激。在所有的任何答案..!

编辑:

我用这个来提交:

  $(函数(){
    $(#skikka)。点击(函数(){
        VAR dendar =
            的http://+
            $(#usernam)VAL()+:+ $(#passwo)VAL()+
            @ twitter.com /状态/ update.xml;

        $(#福曼)ATTR(动作,dendar)。
        $(#福曼)提交()。
        警报(dendar);
        返回false;

    });
});
 

解决方案

下面是使用 JQuery的,这可能是做AJAX不必投入太多的时间学习它的最简单方法。虽然这听起来像你必须学习一门其他技术(jQuery的),它确实是没有那么难。它通常只涉及添加一个更多的JavaScript包括文件引用的页面。

  $。员额(dendar,$(#福曼)序列化());
 

使用jQuery 这里

既然你回发到不同的领域,你必须做额外的工作一点点。看看这篇文章在使用JSONP针对微博

此外,这里是一个jQuery插件,专门为工作对微博: jTwitter

I had a similar question posted here a few hours ago, just now I got the answer that I should look into using AJAX to do this. Since I want to complete this part of the site today I can't afford to learn AJAX from the basics to do this now.. This shouldn't be something difficult and I thougt that I would be able to do this but I'm not skilled enough...

I have a form, when you click submit, it posts to twitter.com/statuses/update.xml and I need to be able to do so without being redirected there.

Is there an easy way to do this or do I need to learn AJAX?

Thankfull for any answer at all..!

edit:

I'm using this to submit:

$(function() {  
    $("#skikka").click(function() {  
        var dendar = 
            "http://" + 
            $("#usernam").val() + ":" + $("#passwo").val() +
            "@twitter.com/statuses/update.xml";

        $("#formen").attr("action", dendar);
        $("#formen").submit();
        alert(dendar);
        return false;

    });  
});

解决方案

Here is a quick example using JQuery, which is probably the easiest way to do AJAX without investing too much time learning it. Although it sounds like you'd have to learn a whole other technology (Jquery) it really isn't that hard. Mostly it just involves adding one more javascript include file reference to the page.

    $.post(dendar , $("#formen").serialize());

More Details on AJAX with Jquery here.

Since you are posting back to a different domain, you will have to do a little bit of extra work. Check out this article on using JSONP against twitter.

Also, here is a JQUERY plugin specifically for working against twitter: jTwitter

这篇关于如何停止的形式submittion后重定向?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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