Aviv
Aviv

Reputation: 75

Delay loading parts of a webpage with jQuery problem

I have a webpage with a div id="rate". I want to load the content of this div after the page is load with jQuery.
When queried, my server returns a VALID xhtml document (with a content type of "application/xhtml+xml") with what should be the contents of the rate div.

I have tried:

$('#rate').load('/wizard/false', function() {
    $("#rate").show("slow", function () {} );
});

As well as $.get - nothing seems to work. I keep getting An invalid or illegal string was specified" code: "12 or hierarchy error (on all browsers).
When I place the content manually directly in the rate div, everything works fine.
You can check out the problematic page here.

Upvotes: 0

Views: 901

Answers (1)

Joseph Silber
Joseph Silber

Reputation: 220136

Your xHTML that you are trying to load is not valid xHTML.

It starts with a doctype declaration, but has no 'html', 'body' or 'head' tags.

Try either removing the doctype, or putting in all those tags.

If you add those tags, you can then strip them by providing jQuery with the ID of the element that you want:

$('#rate').load('/wizard/false #rating-wizard', function(data) {
    // Do whatever you want
});

Look at the jQuery Documentaion for .load. Look for the heading "Loading Page Fragments".

Upvotes: 2

Related Questions