Edit: Important: It is extremely unlikely that anybody who has come across this will have the exact same problem as me - check my answer below for my very obscu
Wow! Well that was crazy.
Turns out the problem is because of this code that I have in an included JS file:
jQuery.fn._init = jQuery.fn.init
jQuery.fn.init = function(selector, context) {
if (typeof selector === 'string') {
return jQuery.fn._init(selector, context).data('selector', selector);
}
return jQuery.fn._init(selector, context);
};
I am using jQuery 1.2.6.
The code above came from this post How do I get a jQuery selector's expression as text?. i think the author since rewrote it, but its breaking this for some strange reason.
The DIV just disappears - but i got thrown because replaceWith() DID work and so did append(). I guess some of the other methods mus internally being tripped up by this but those two werent.
Thanks for everyones quick suggestions. I'm sure they'll help out others some point.
Check the ID of your div, make sure the correct ID is being passed on to jquery.
Perhaps try this?
$.get("/woops/store/cartsummary", {}, function(data) {
$("#cart").html(data);
});
append
does not replace your div. It pastes the data at the back of your div.
You could try
replaceWith( content )
instead.
replaceWith in jQuery documentation
try
$.get("/woops/store/cartsummary", {}, function(data) {
$("#cart").html(data);
});
(jQuery docs)