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 6032259
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T05:18:27+00:00 2026-05-23T05:18:27+00:00

I have the following: $.post(baseUrl+/index/voto,{id:eid},function(e){ var divMsg = $(#msg); var html = ; if(e.msg

  • 0

I have the following:

$.post(baseUrl+"/index/voto",{id:eid},function(e){
 var divMsg = $("#msg");
 var html = "";
   if(e.msg == 1){
     html = '<img src="'+baseUrl+'/lib/img/showImageA.png" alt="pdf" />';
   }else if(e.msg == 3){
     //HERE I MUST DISPLAY A TEXT AFTER A GIVEN ELEMENT
   } else if(e.msg == 2){
     html = '<img src="'+baseUrl+'/lib/img/showImageB.png" alt="pdf" />';
   } else{
     html = '<img src="'+baseUrl+'/lib/img/showImageC.png" alt="pdf" />';
   }
   divMsg.show();
   divMsg.html(html); 

}, 'json');

So, if something arrives, I will replace the content with an image.
This works.

The issue is that, on the second case (e.msg ==3) I should not remove or replace the all thing with an image, but I need to append an element p on a specific place saying: “something”.

I tried to display:none; that element and then add:

else if(e.msg == 3){
 myParagrafId.show();
}

Nothing appears.

I tried to:

else if(e.msg == 3){
 $('#foo').append('<p>Something</p>');
}

Still nothing…

The function seems to be returning the html, ignoring my instructions inside the second conditional.

So, perhaps I need to grab the existing html part, append what I need, and then allow the function to output it ?

Additional note:
If I place an alert(); inside that condition (e.msg == 3) it works.

  • 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-23T05:18:28+00:00Added an answer on May 23, 2026 at 5:18 am

    First af all you are always putting html into $("#msg") here

    //in case 3 html = ''
    divMsg.html(html);
    

    so you should check it’s not an empty string:

    if (html != ''){
        divMsg.html(html);
    }
    

    So if you were trying to do somenthing inside $("#msg") (like showing an hidden div inside it) in case 3 it does nothing because it gets replaced by ” because you are calling $("#msg").html('');

    does this help?

    Otherwise you are doing something wrong in that if, if you show your markup we can help

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

Sidebar

Related Questions

I have the following post-commit hook setup and running: #!/bin/bash /usr/bin/svn update /var/www/html/dev >
I have following html form: <form method=post action=> <input type=hidden name=userid id=user value=<?php echo
I have following linq expression: var files = posts .Select(post => int.Parse(post.Length.ToString()[0].ToString())) .GroupBy(c =>
I have the following function to post to Facebook using the latest iOS Facebook
I have the following $.post() function that expects JSON as its return value. $.post($(this).attr(action),
All, I have the following code: $.post(save.php, {rate: value, vendor: vendor_id}, function(results) { alert(results);
I have following code $.ajax({ type: 'POST', url: 'index.jsp', data: 'id=111', dataType: 'jsonp', success:
I have been following the following post on using multiple ItemTemplates in a ListView
I have the following code: // // POST: /PlayRoundHole/Create [AcceptVerbs(HttpVerbs.Post)] public ActionResult Create(FormCollection collection)
i have the following javascript to post a form through ajax without refreshing the

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.