我正在使用 jquery Ajax 以下代码行,仅对Firefox和Blackbarry浏览器有问题
职位:
navigator.geolocation.getCurrentPosition(currentPosition);
function currentPosition(res){
window.res = res;
}
代码:
var postion = window.res;
$.ajax({
url: 'SendLocation',
type: 'post',
data: position, // Position is navigator.geolocation.getCurrentPosition
success: function(res){
alert(res);
}
});
错误:
NS_ERROR_XPC_BAD_OP_ON_WN_PROTO: Illegal operation on WrappedNative prototype object
value = jQuery.isFunction( value ) ? value() : ( value == null ? "" : value );
在阅读FormData Object not submit via jQuery AJAX call post后,我添加了以下代码行,代码变为 processData: false, contentType: false,
更新代码:
$.ajax({
url: 'SendLocation',
type: 'post',
data: position, // Position is navigator.geolocation.getCurrentPosition
processData: false, //Added this line
contentType: false, //Added this line
success: function(res){
alert(res);
}
});
这样没有错误发生,但代码也停止工作。