Php 如何在jqueryajax中提交来自div的所有数据?

Php 如何在jqueryajax中提交来自div的所有数据?,php,jquery,ajax,Php,Jquery,Ajax,我目前正在使用此脚本每秒从jQuery ajax中的record_count.php获取新数据,然后将其放置在notifications_load div中。但我想知道如何让脚本将notifications_load中的所有当前内容提交到record_count.php,以便我可以使用$_POST获取数据。谁能告诉我怎么做?谢谢: 源代码: <?php include('../general_scripts/connect.php'); $or ?> <!DOCTYPE h

我目前正在使用此脚本每秒从jQuery ajax中的record_count.php获取新数据,然后将其放置在notifications_load div中。但我想知道如何让脚本将notifications_load中的所有当前内容提交到record_count.php,以便我可以使用$_POST获取数据。谁能告诉我怎么做?谢谢:

源代码:

<?php
include('../general_scripts/connect.php');

$or

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /></head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/
libs/jquery/1.3.0/jquery.min.js"></script>
<script type="text/javascript">
var auto_refresh = setInterval(
function ()
{
$.ajax({
    url: 'record_count.php',
    type: 'GET',
    success: function(result) {
        if (result != null && result != '') {
            $('#notifications_load').html(result);
        }
    }
});
}, 10000); // refresh every 10000 milliseconds

<body>
<div id="notifications_load"> <?php
$sql=mysql_query("select * from updates ORDER BY update_time DESC LIMIT 9");
while($row=mysql_fetch_array($sql))
{
$msg_id=$row['update_time'];
$message=$row['item_content'];
?>

<?php echo $message; ?>

<?php } ?> </div>

</script>
</body>
</html>

我不是100%确定你想通过这样做来完成什么,但是如果你只想抓取一个div的内容并将其提交到一个url,你可以这样做:

function submitData(id, url) {
    var content = $('#'+id).html();
    $.ajax({
        'url' : url,
        'type' : "POST",
        'data' : 'content='+encodeURI( content );
    });
}

submitData('notifications_load','record_count.php');