Max
Max

Reputation: 1334

insert html content inside a class in jquery

I am using jquery to insert html content like,

$.get("_html/saveme.html", function(data){
    $(".saveWin .modalCSS").html(data); //Error here
});

In Firefox it is giving me error as,

Node cannot be inserted at the specified point in the hierarchy

In IE it is working fine. Please suggest me, are there any other ways to call class inside a class and insert html content.

Thanks in advance

Upvotes: 0

Views: 321

Answers (2)

Max
Max

Reputation: 1334

Okay, I just found the answer...

Instead of calling like,

$.get("_html/saveme.html", function(data){
    $(".saveWin .modalCSS").html(data); //Error here
});

If I call,

$.ajax({ 
    url: "_html/saveme.html",
    type: "get",
    dataType: "text",
    success: function(data) {
    $(".saveWin .modalCSS").html(data);
    }
});

This works. Thanks a lot for your time guys.

Upvotes: 1

jrharshath
jrharshath

Reputation: 26583

I cannot be sure what the issue is exactly coz I don't have enough details.

But I can tell you how to figure it out: Use Firebug. Add these statements in your Ajax callback:

console.log( $(".saveWin .modalCSS") );
console.log(data);

Check if $('.saveWin .modalCSS') is turning up any results. See what the value of data is.

Since it works in IE, there is something peculiar going on. Use Firebug to debug the problem.

Cheers :)

Upvotes: 2

Related Questions