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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T06:27:20+00:00 2026-06-09T06:27:20+00:00

Line of bug is this: contxt.replaceWith(safe_copy[id]).prepend(<span class=’error’>+jsonObj.data+</span>); While the replaceWith statement works just fine

  • 0

Line of bug is this:

contxt.replaceWith(safe_copy[id]).prepend("<span class='error'>"+jsonObj.data+"</span>");

While the replaceWith statement works just fine the data is not getting ‘prepended‘.

A more complete code:

contxt = $(this).parents('div[style^="display"]');
id = $(this).attr('id');

        $.ajax({
                url: "/submit/myposts",
                type: "POST",
                data: "action=edit&post="+$(this).attr('id').match(/[0-9]+/)[0]+"&data="+encodeURIComponent(text),
                success: function(data){
                    loading.remove();
                    jsonObj = $.parseJSON(data);

                    if(jsonObj.code == "0")
                        block.html(jsonObj.data);
                    else
                        contxt.replaceWith(safe_copy[id]).prepend("<span class='error'>"+jsonObj.data+"</span>");
                },
                error: function(){
                    loading.remove();
                    contxt.replaceWith(safe_copy[id]).prepend("<span class='error'>An error occurred. Please try again.</span>");
                }
            });
  • 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-09T06:27:22+00:00Added an answer on June 9, 2026 at 6:27 am

    .replaceWith() returns the original jQuery object (the one removed from the page) so when you chain onto it, it will operate on the content that was removed, not the content that was added.

    From the jQuery Doc for .replaceWith():

    The .replaceWith() method, like most jQuery methods, returns the
    jQuery object so that other methods can be chained onto it. However,
    it must be noted that the original jQuery object is returned. This
    object refers to the element that has been removed from the DOM, not
    the new element that has replaced it.

    I’m not entirely sure I understand your code/HTML, but this might be one possible work-around:

    var newContent = $(safe_copy[id]).prepend("<span class='error'>"+jsonObj.data+"</span>");
    contxt.replaceWith(newContent);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

OK, so this code below sometimes crashes on the line below //bug!! The error
I have a bug in this conditional: while(CurrentObserverPathPointDisplacement > lengthToNextPoint && CurrentObserverPathPointIndex < (PathSize
Given this bug (Python Issue 4892) that gives rise to the following error: >>>
Can you find a bug in this line of code? It returns nil!! The
I am stuck with this error: while trying to use an old DLL in
We have a Coverity bug for this line of code: snprintf( tempStr, size, testStrings[testID],
The bug starts at cin.getline ( string, 25, '\n' ); or the line below
line = english: while french: pendant que spanish: mientras german: whrend words = line.split('\t')
This line of code: DateTime dt = DateTime.ParseExact(time, hh:mm, CultureInfo.InvariantCulture); parses a time value
This line of code ((Matches)Container.DataItem).MatchID works in C# but in VB.NET, when used in

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.