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

  • Home
  • SEARCH
  • 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 4034504
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T11:58:49+00:00 2026-05-20T11:58:49+00:00

In my php page, I’ve three lists ul#line, ul#comment, ul#vote. I’m going to make

  • 0

In my php page, I’ve three lists ul#line, ul#comment, ul#vote.

I’m going to make an ajax call, something like

           $.ajax({
        type: "POST",
        url: "ajax.php",
        data: dataString,

        cache: false,
        success: function(html){
            $("ul#line").append(html);
            $("ul#lineli:last").fadeIn("slow");
    }

Ajax.php is something like

if(isset($line)){
    echo $line;
} elseif(isset($comment)){
    echo $comment;
} elseif (isset($vote)){
    echo $vote;
} else {
   //do nothing;
}

What I want is, if the echoed out HTML is $line, it’ll be appended to ul#line; if it is $comment, it’ll be appended to ul#comment; if it is $vote, it’ll be appended to ul#vote.

The current ajax call appends only at ul#line.

What do I need to change to achieve this??

  • 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-05-20T11:58:50+00:00Added an answer on May 20, 2026 at 11:58 am

    php

    class DataObject
    {
        public $Type;
        public $Text;
    }
        $json=new DataObject();
    
    if(isset($line)){
        $json->Type="line";
        $json->Text=$line;
        return json_encode($json);
    } elseif(isset($comment)){
        $json->Type="comment";
        $json->Text=$comment;
        return json_encode($json);
    } elseif (isset($vote)){
        $json->Type="vote";
        $json->Text=$vote;
        return json_encode($json);
    } else {
       //do nothing;
    }
    

    javascript

        $.ajax({
        type: "POST",
        url: "ajax.php",
        dataType: 'json',  //add data type
        data: dataString,    
        cache: false,
        success: function(data){
            $("ul#"+data.type).append(data.text);
            $("ul#"+data.type+"li:last").fadeIn("slow");
         }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have index.php page which makes a ajax call to thread.php by sending the
I have one php page like this <script type=text/javascript src=js/jquery.min.js></script> <script type=text/javascript> window.onbeforeunload =
I have a PHP page that needs to make a call to a external
I've created a php page with two forms but I would like to have
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a dynamic php page which I need to call with a get
Scenario: I have a php page in which I call a python script. Python
I have a functions.php page with a simple textarea, like this: <tr valign=top> <th
In a php page I have placed a submit button, HTML: <input type=submit name=btnAdd
On the page 'selecteditems.php' I have a form like this: <form method=POST name=selecteditems action=nextpage.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.