将表单数据插入数据库后无法重定向到html页面 [英] Unable to redirect to html page after inserting form data into database

查看:65
本文介绍了将表单数据插入数据库后无法重定向到html页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

$("#sub").click( function() {                                 
    $.post($("#new_user").attr("action"), $("#new_user :input").serializeArray(), function(info) { 
        $("#result").html(info);  
    });  
    clearInput();  
});  

$("#new_user").submit(function() {  
    return false;  
}); 

function clearInput() {  
    $("#new_user :input").each(function() {  
        $(this).val('');  
    });  
}  

此处sub是HTML表单的ID,result是与表单在同一页面中的span标记的ID.我希望在插入数据库后重定向到相同的HTML页面,这是没有发生的.插入操作正确进行.

Here sub is the id of the HTML form and result is the id of a span tag in the same page as the form. I am looking to redirect to the same HTML page after inserting in the database, which is not happening. Insertion is happening properly.

推荐答案

使用此方法重新布局

window.location = "http://www.youtube.com";

或在您要重定向的函数中使用它

or use this in your function where you want to redirect

$(this).attr("href","http://www.youtube.com");

提供您自己的网址

这篇关于将表单数据插入数据库后无法重定向到html页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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