我在从这个ajax调用返回HTML时出现问题。它在FF中工作正常,但在IE中为我提供了一个“null”alert(result.html());
Ajax调用问题
这里是代码。有任何想法吗?谢谢!!!
IE中的errors变量也为null。
此外,它不会影响我在.find()
中使用的元素,因为它仍然为空。
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>');
}
});
}
$(function() {
$("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;
});
});
});
这是来自Ajax调用的HTML。
<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>
在FF我得到这个警报。
<span class="price_name"> Price with added options: </span><span class="price1">$505.00</span>
你希望有人通过猜测你的HTML是什么来调试你的工作。你为什么不把这个例子发布在jsFiddle或者有用的东西上?你为什么不描述你使用的是什么版本的IE? – vol7ron 2010-11-28 03:13:47
IE8,我已经用Ajax调用的HTML片段更新了问题 – user357034 2010-11-28 03:24:32