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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T06:11:18+00:00 2026-05-26T06:11:18+00:00

Hello fellow Stackoverflow users, I have a page which does a AJAX request to

  • 0

Hello fellow Stackoverflow users,

I have a page which does a AJAX request to update the shoppingcart.
The problem is that the cart has some inline javascript which breaks the page on the ajax request.

The following is the ajax request i use:

    $.ajax({
        url: "Default.aspx?ID=5&productid=PROD147&cartcmd=add",
        success: function () {
            $.ajax({
                url: "Default.aspx?ID=5",
                dataType: "html",
                cache: false,
                success: function(html){
                    $(html).remove('script');
                    console.log(html);
                    var ajax_shoppingcart = $('#shoppingcart',html).html(); 
                    $('#shoppingcart').html(ajax_shoppingcart);
                    var ajax_basket = $('#topbanner_eshop',html).filter(":not(script)").html(); 
                    $('#topbanner_eshop').html(ajax_basket);
                  }
            });
        }
    });

But the problem is that the data it loads into #topbanner_eshop contains some inline javascript, which breaks the page.

It tries to import the following html:

<div id="topbanner_eshop">
    <div>
        <div>
            <a href="Default.aspx?ID=24">Shop videre » </a>
        </div>
        <div>
            2 varer i kurven
        </div>
        <div>
            Total
        </div>
        <div>
            <script type="text/javascript"> 
            // var str="190,00"; 
            var str="DKK 190,00"; 
            document.write(str.replace(/,00/, ",-")); 
            </script>
        </div>
    </div>
</div>

But when it reaches the inline script it replaces the whole page with the script result.

What did i do wrong?

  • 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-26T06:11:19+00:00Added an answer on May 26, 2026 at 6:11 am

    Well, for one thing, there’s this:

     $(html).remove('script');
    

    You’re explicitly removing the script elements.

    Then, the actual script uses “document.write()”, which, once the containing page has been loaded, will implicitly destroy it. In other words, calling “document.write()” implicitly calls “document.open()”, which, in turn, erases the DOM.

    Instead of “document.write()”, you could do this:

    <span id='amount'></span>
    <script>
      var str = "DKK 190,00"; // I presume that's actually a server-side thing
      $('#amount').text(str.replace(/,00/, ',-'));
    </script>
    

    It would be a lot better to just fix the string with server-side code.

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

Sidebar

Related Questions

Hello again stackoverflow... Once again I have a troublesome problem. I have a page
Hello fellow programmers. I have a SQL Server 2005 query that is taking a
Hello fellow StackOverflow users (or Stackoverflowers ?): I'm learning-by-coding WPF. I read several articles/saw
Hello fellow drupalers, I have a question about ajax loaded views. Lets say i
Hello fellow computer people :) I have a shell script that I will use
Hello my fellow programmers, I have a problem (other than not knowing enough) I
Hello fellow stackoverflow-ers, I built an ajax image gallery and used asual' jquery address
Hello I have the following error by git-fsck, which cannot be cleaned by git-gc
Hello fellow C++ programmers. I have, what I hope to be, a quick question
Hello Fellow stackoverflowers, I´m stuck writing a piece of code. I have application with

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.