Broken jQuery 1.4.2 functionality?
This code worked prior to the upgrade from 1.3.2. to 1.4.2 and now I'm getting this error I don't know what to do with...:
jQuery.ajax({
type: 'post',
url: '/ajax/store/product/getAssocDetail.ph',
dataType: 'json',
data: {
//productId: (document.location+"").split("=")[1],
vehicleId: id
},
success: function () {/*
if (r.length > 0) {
console.log(r.length);
for (var i = 0; i < r.length; i++) {
jQuery('#condition-'+i+'-price').val(r[i].price);
jQuery('#condition-'+i+'-bid').val(r[i].bid);/*
if (parseInt(r[i].on_amazon) == 1) {
jQuery('#on_amazon-'+i+'-yes').attr('checked', 'checked');
} else {
jQuery('#on_amazon-'+i+'-no').attr('checked', 'checked');
}
console.log('[value='+r[i].on_amazon+']');
console.log(jQuery('#condition-'+r[i].condition_id+'-on_amazon').filter('[value='+r[i].on_amazon+']'));
jQuery('#condition-'+r[i].condition_id+'-on_amazon').filter('[value='+r[i].on_amazon+']').attr('checked', true);
}
jQuery('#assocation-detail').show();
} else {
triggerNotification('x', 'Could not find any assocation data');
}*/
},
error: function () {
//document.triggerNotification('x', 'Unable to process your request, ajax file not found');
return false;
}
});
uncaught exception: [Exception... "Illegal operation on WrappedNative prototype object" nsresult: "0x8057000c (NS_ERROR_XPC_BAD_OP_ON_WN_PROTO)" location: "JS frame :: http://internal.ikeyless/js/jquery/jquery-1.4.2.min.js :: f :: line 132" 开发者_开发技巧 data: no]
Line 0
update
The error appears to be here on line 5437 of uncompressed jQuery 1.4.2 (http://code.jquery.com/jquery-1.4.2.js)
function add( key, value ) {
// If value is a function, invoke it and return its value
value = jQuery.isFunction(value) ? value() : value;
s[ s.length ] = encodeURIComponent(key) + "=" + encodeURIComponent(value);
}
update
The issue was that one of the values being posted via ajax was a dom node :-\
The issue was that one of the values being posted via ajax was a dom node :-\
Why this happens:
jQuery is trying to serialise the node as a generic {}
-style object lookup. Using a for..in
loop it fetches each property of the node including DOM methods like appendChild
. The add
function quoted checks to see whether the value is a function, and if so, calls it. A method is a function, so it calls node.appendChild
as a plain function, without this
set to point to an actual Node
instance. This causes the characteristic XPC error.
jQuery 1.3 did not have the (rather pointless IMO) feature of being able to pass a callable function into a parameter mapping, so you don't get this error. It's still not sensible to serialise a DOM Node, but it fails silently instead of blowing up.
You need to wrap the fadeOut
code in an anonymous function...
document.triggerNotification = function (type, message) {
jQuery(document.body).append("<div class='push-notification push-"+type+"' id='notification'>"+message+"</div>");
setTimeout(function(){
jQuery('#notification').fadeOut(1200, function () {
jQuery('#notification').remove();
})
}, 3000);
}
jQuery(document.body)
seems a bit suspicious to me, though cannot be too sure.
Try jQuery("body")
instead.
This link is kind-of loosely-related and was caused my aliasing document.createElement
. Sounds like this may be the same thing.
Can you verify on which line it is actually failing?
精彩评论