开发者

How do i submit all data from a div in jQuery ajax?

I am currently using this script to get new data every second from record_count.php in jQuery ajax then place it in the notifications_load div. But i am wondering how i can get the script to submit all the current content in notifications_load to record_count.php so i can use a $_POST to get the data. Can anyone tell me how i can do this? Thanks :)

Source code:

<?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 = setInte开发者_如何学JAVArval(
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>


I'm not 100% sure what you're trying to accomplish by doing this, but if all you want to do is grab the contents of a div and submit it to a url, you could do this:

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

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜