Javascript Ajax调用问题
从这个ajax调用返回HTML时遇到问题。它在FF中运行良好,但在IE中为alertresult.html提供了null 这是代码。有什么想法吗?谢谢 在IE中,errors变量也为null 另外,我在.find中使用什么元素也没有区别,因为它仍然是空的Javascript Ajax调用问题,javascript,jquery,ajax,Javascript,Jquery,Ajax,从这个ajax调用返回HTML时遇到问题。它在FF中运行良好,但在IE中为alertresult.html提供了null 这是代码。有什么想法吗?谢谢 在IE中,errors变量也为null 另外,我在.find中使用什么元素也没有区别,因为它仍然是空的 function update_price() { $.ajax({ url: $("form[name='MainForm']").attr('action'), data: $("form[name=
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>
此代码可能有错误
var errors=$(response).find("#listOfErrorsSpan");
var result=$response.find.colors\u产品价格:eq0;
alertresult.html
我不确定$response的选择器是否未定义您的find语句中的:eq0可能是问题所在。只要说find.colors\u productprice就足够了。你没有
不确定这是否是根本问题,但FF和IE在quirksmode中的工作方式不同,特别是在动态向DOM中插入元素时。我不这么认为,因为没有生成javascript错误,在FF中工作正常。就是不知道为什么?也许这是获得响应的错误方法。删除该行在IE中也有同样的效果。您希望有人通过猜测HTML来调试您的工作。为什么不在JSFIDLE或其他有用的工具中发布这个示例?你为什么不描述一下你正在使用的IE的哪个版本呢?IE8,我已经用Ajax callIts中的HTML片段更新了这个问题,而不是class=colors\u productprice的唯一元素,因为我只显示了相关的HTML。不过是Thx。