开发者

Ajax call problem

开发者 https://www.devze.com 2023-01-27 11:25 出处:网络
I am having problems returning the HTML from this ajax call. It works fine in FF but gives me a \"null\" in IE for the alert(result.html());

I am having problems returning the HTML from this ajax call. It works fine in FF but gives me a "null" in IE for the alert(result.html());

Here is the code. Any ideas? Thanks!!!

The errors variable is also null in IE.

Also, it makes not difference what element i use in the .find() as it still comes up null.

function update_price() {
    $.ajax({
        url: $("form[name='MainForm']").attr('action'),
        data: $("form[name='MainForm']").serialize() + '&btnupdateprice.x=0&btnupdateprice.y=0',
        type: 'POST',
        cache: false,
        success: function (response) {
            var errors = $(response).find("#listOfErrorsSpan");
            var result = $(response).find(".colors_productprice:eq(0)");
            alert(result.html());
            $(".colors_productprice:eq(0)").replaceWith('<font class="colors_productprice">' + result.html() + '</font>');
            $('#listOfErrorsSpan').replaceWith('<span id="listOfErrorsSpan">' + errors.html() + '</span>');
        }
    });
}

$(functio开发者_高级运维n () {
    $("select[name^='SELECT___'],input[name^='SELECT___'][type='radio']").each(function () {
        $(this).change(function () {
            update_price();
        });
    });
    $("a[href^='javascript:change_option']").each(function () {
        $(this).click(function () {
            var result_href = $(this).attr('href').match(/\'(.*?)\'/)[1];
            var result_val = $(this).attr('href').match(/\,(.*?)\)/)[1];
            change_option(result_href, result_val);
            update_price();
            return false;
        });
    });
});

Here is the HTML from the Ajax call.

<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
<b><font class="pricecolor colors_productprice"><span class="price_name"><font class="text colors_text"><b>Our Price: </b></font></span>
<span class="price1">$505.00</span>
</font>
</b>
</tr>
</table>

In FF I get this for the alert.

<span class="price_name"> Price with added options: </span><span class="price1">$505.00</span> 


you might have errors on this code

var errors=$(response).find("#listOfErrorsSpan");

var result=$(response).find(".colors_productprice:eq(0)"); alert(result.html());

i am not sure maybe the selector for $(response) is undefined


The :eq(0) in your find statement may be the problem. It is probably sufficient to just say find(".colors_productprice").


You don't have </td>

Not sure this is the root problem, but FF and IE work differently in quirksmode, especially when inserting elements into the DOM on the fly.

0

精彩评论

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