开发者

selecting from Jquery success result

开发者 https://www.devze.com 2023-03-30 03:47 出处:网络
I\'m trying to update a part of a page after the success of an asynchronous post. So I have: success: function (data, status, xhr) {

I'm trying to update a part of a page after the success of an asynchronous post.

So I have:

success: function (data, status, xhr) {
        var elementName = "#div" + gridName;
        var findResult = $(data).find(elementName);
        $(elementName).html($findResult);

Now when I view data the HTML looks like:

<div class="t-grid-header">
<div class="t-grid-header-wrap">
<table cellspacing="0">

but when I inspect the HTML from findResult it looks like:

<DIV class=t-grid-header>
<DIV class=t-grid-header-wrap>
<TABLE cellSpacing=0>

Thi开发者_JS百科s is not 'good' Html so I can't use it. So how do I get good HTML. findResult.html() doesn't work because the call is too late. The conversion has already happened.

How do I proceed?


I will guess that you are using some version of IE before IE9. It is quite common that when you fetch the innerHTML in older versions of IE, the result looks very different than what you put in (including capitalization, quoting of attributes, order of attributes, etc...). This is what these older versions of IE do.

Fortunately for you, any browser that creates that innerHTML when you fetch it, will also accept that innerHTML when you set it so you shouldn't need to worry. Try this in a non-IE browser (or in IE9) and I don't think you will see the same thing.


Why do you care about "html" is wrong? If it's because of crawlers, do not worry. They do not use javascript on your page.

0

精彩评论

暂无评论...
验证码 换一张
取 消