Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8350235
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T08:15:16+00:00 2026-06-09T08:15:16+00:00

I’m trying to insert my comment content with Ajax. But I believe I’m having

  • 0

I’m trying to insert my comment content with Ajax. But I believe I’m having trouble with the comment_add.php page and wondered if someone could take a look for me.

Getting the streamid seems to work as I’ve checked in firebug, but it shows no content. So I don’t know whether I may have missed something that I can’t see but someone else might be able to find. Or maybe I just haven’t written the comment_add page properly.

FORM

echo "<form id='addcomment' method='POST' class='form_statusinput'>
<input type='hidden' name='posterid' id='posterid' value='".$user1_id."'>
<input type='hidden' name='streamid' id='streamid' value='".$streamitem_data['streamitem_id']."'>
<input name='content' id='content' placeholder='Comment..' autocomplete='off'>
<input type='submit' id='button' value='Feed'>
</form>";

AJAX

<script>
$(document).ready(function(){
$("form#addcomment").submit(function(event) {
event.preventDefault();
var content = $("#content").val();
var streamid = $("#streamid").val();

$.ajax({
type: "POST",
url: "comment_add.php",
dataType: "json",
data: {content:content,streamid:streamid}, 
success: function(response){ 
$("#commentaddid").prepend(""+content+"");
}
});
});
});
</script>

COMMENT_ADD.PHP

<?php
session_start();
require"include/load.php";
$user1_id=$_SESSION['id'];
if(isset($_POST['streamid'])&isset($_POST['content'])){
if($_POST['content']){
rawfeeds_user_core::add_comment($_POST['streamid'],$_POST['content']);
}
}
?>

FUNCTION

public function add_comment($streamid,$content){
            $content =  mysql_real_escape_string($content);
            $content =  strip_tags($content);

            $content = preg_replace('/(?<!S)((http(s?):\/\/)|(www.))+([\w.1-9\&=#?\-~%;\/]+)/','<a href="http$3://$4$5">http$3://$4$5</a>', $content);

            if(strlen($content)>0){
            $insert = "INSERT INTO streamdata_comments(comment_poster, comment_streamitem, comment_datetime, comment_content) VALUES (".$_SESSION['id'].",$streamid,UTC_TIMESTAMP(),'$content')";
                        echo $insert;

            $add_post = mysql_query($insert) or die(mysql_error());
            }
            return;
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T08:15:17+00:00Added an answer on June 9, 2026 at 8:15 am

    change

    success: function(response){ 
    $("#commentaddid").prepend(""+content+"");
    }
    

    to

    success: function(response){ 
    $("#commentaddid").prepend(""+response+"");
    }
    

    because content doesn’t exist in that function

    AND

    your links wouldn’t be <a>‘s

    EDIT 2
    Because you wanted to add the data from the other side here is a little hack you can use to get content

    $.ajax({
    type: "POST",
    url: "comment_add.php", 
    dataType: "json",
    _content:content,
    data: {content:content,streamid:streamid},  
    success: function(response){  
        $("#commentaddid").prepend(""+this._content+""); 
    } 
    });
    

    This is possible because the constructor loop through the object and sets it to this

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
Basically, what I'm trying to create is a page of div tags, each has
I want to count how many characters a certain string has in PHP, but
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm trying to create an if statement in PHP that prevents a single post
I'm having trouble keeping the paragraph square between the quote marks. In firefox the
I am trying to understand how to use SyndicationItem to display feed which is
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I would like to count the length of a string with PHP. The string
this is what i have right now Drawing an RSS feed into the php,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.