Prepend to DOM after Ajax Refresh

Posted on 2013-01-03
Last Modified: 2013-01-10
Hello, I am using a shopping cart that is very restrictive and I cannot edit what I need to. I am trying to add some text to a DIV using Jquery's .prepend() method, but the DIV that I need to access it not created until the 4th step of the checkout, which is refreshed in between each step.

The checkout is at
Feel free to add any product to the cart and go to the checkout page to see how it updates.

Here is the code that I want to add:
<script>$('#ctl00_pageContent_divEditAddress').prepend('<h1>Billing Address</h1>');</script>

Open in new window

That is supposed to add the heading "Billing Address" before the Edit link on the Payment step. Please let me know if you need any more info. Thanks!!
Question by:lowpriceskates
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
LVL 11

Expert Comment

ID: 38743424
I've gone till where credit card info is requested and didn't find the div your addressing in your code? Is this a trick to make us buy some rollers?? ;-)
LVL 25

Expert Comment

by:Kyle Hamilton
ID: 38743470
I see the link.

You can't do it from jquery if that part of the page is refreshed with AJAX, unless there is a callback supplied to the AJAX call. Which I'm guessing it is not. You can contact the author of the javascript does the AJAX - that's about it.

Is there not template file where you can find the spot to add the HTML?
LVL 25

Expert Comment

by:Kyle Hamilton
ID: 38743480
however, if it helps, you can style the link itself to be more obvious:

font-size: 18px;

   content: 'Billing Address';

That should give you a large: "Edit Billing Address" label
MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.


Author Comment

ID: 38745052
Thanks for that CSS, kozaiwaniec. That is somewhat helpful, but does not solve my original problem. Is there no way to have Jquery code execute on each refresh of a page? For each time the page is changed or loaded the code is executed?
LVL 25

Expert Comment

by:Kyle Hamilton
ID: 38745080
you can definitly execute the code on pageload. but when the page content is updated via ajax, it is not reloaded.

to execute on page load wrap your function in the docready function.


//your code


Author Comment

ID: 38756706
I've requested that this question be deleted for the following reason:

No valid answers.
LVL 25

Expert Comment

by:Kyle Hamilton
ID: 38756707
the answer is you cant do what you are asking for given the circumstances. that is a valid answer.

Author Comment

ID: 38756725
I don't agree, I'm sure that it's possible but I'm not going to argue about it.

Author Comment

ID: 38756727
Not actually a solution.
LVL 25

Accepted Solution

Kyle Hamilton earned 500 total points
ID: 38756832
like i said in a prior post, you need a callback in the ajax request.

Featured Post

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Check input text, Number 7 52
object method as an event handler 8 71
PDF Turn Look 7 27
What is the valid CSS Selector Chain for this situation? 3 6
PROBLEM: The other day I was working on adding an ajax request to a webpage that already had a dialog box on the page.  The dialog box was using relative positioning to be positioned next to a form field I had on the page.  Everything was working…
Introduction If you're like most people, you have occasionally made a typographical error when you're entering information into an online form.  And to your consternation, the browser remembers the error, and offers to autocomplete your future entr…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question