gpt4 book ai didi

javascript - Ajax、JavaScript、PhP 从 td 获取值并将其保存在 SQL 数据库中

转载 作者:行者123 更新时间:2023-12-03 11:05:19 25 4
gpt4 key购买 nike

当我单击特定的 td 并将该值保存在 SQL 数据库中时,如何获取 td 的值。该表是这样构建的:

$calendar.= '<td class="calendar-day" value="'.$current_day.'">';
$calendar.= '<p>Nurse: '.$nurse_number.' </p><p>Senior: '.$senior_number.' </p>';
$calendar.= '</td>';

非常感谢!

最佳答案

你必须使用ajax。这是示例代码:

var xmlhttp;
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("myDiv").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","ajax_info.txt",true);
xmlhttp.send();

或者如果您使用 jquery,则语法如下:

$.ajax({
type: "POST",
url: "some.php",
data: { name: "John", location: "Boston" }
})
.done(function( msg ) {
alert( "Data Saved: " + msg );
});

有关更多信息,请阅读:ajax

关于javascript - Ajax、JavaScript、PhP 从 td 获取值并将其保存在 SQL 数据库中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27887697/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com