你好,你所有的程序員,以及我有一個jQuery標籤的問題。我使用jQuery的選項卡之間導航,和jQuery代碼如下所示:jquery選項卡,如何重定向?
$(document).ready(function() {
//Default Action
$(".tab-content").hide(); //Hide all content
$("ul.vertical-tab li:first").addClass("active").show(); //Activate first tab
$(".tab-content:first").show(); //Show first tab content
//On Click Event
$("ul.vertical-tab li").click(function() {
$("ul.vertical-tab li").removeClass("active"); //Remove any "active" class
$(this).addClass("active"); //Add "active" class to selected tab
$(".tab-content").hide(); //Hide all tab content
var activeTab = $(this).find("a").attr("href"); //Find the rel attribute value to identify the active tab + content
$(activeTab).fadeIn(); //Fade in the active content
return false;
});
});
第一個選項卡始終是默認的,所以,當我第二個選項卡上工作,並將數據提交給外部PHP腳本,重定向總是返回我第一個(默認選項卡)。 我的重定向如下所示:header('Location:http://www.administrator.php');
$con=mysqli_connect("localhost","root","","database");
$firstname=$_POST['firstname'];
$lastname=$_POST['lastname'];
$sql="INSERT INTO student (firstname,lastname) VALUES('$firstname','$lastname')";
if (!mysqli_query($con,$sql))
{
die('Error: ' . mysqli_error());
}
header('Location:http://www.administrator.php');
mysqli_close($con);
,因爲我使用jQuery我不能用自己的地址重定向到所需的選項卡。說明:/
我會更擔心你的代碼中的[sql注入攻擊](http://bobby-tables.com)漏洞。插入這些是比一些糟糕的選項卡更大的優先級。 – 2013-04-04 17:04:36
哦,我並不擔心安全問題,因爲我正在爲大學課程寫這個項目,所以我只想工作...... – 2013-04-04 17:08:16
大學課程與否,你會被建議讓它成爲一種習慣來擔心關於安全。 – Rohrbs 2013-04-04 17:16:19