[英]IE 11 ajax error - “SCRIPT65535: Argument not optional”
The code below works in every browser except IE, following an error message "SCRIPT65535: Argument not optional"
. 下面的代码在错误消息
"SCRIPT65535: Argument not optional"
之后在除IE之外的所有浏览器中均有效。
function _getChart(){
$('.series-data').remove();
var itm = window.item;
var tp = window.type;
var ord = window.order;
var xd = window.xdata;
var yd = window.ydata;
var dt = {superAwesomeTypeNotIEvar : tp,
superAwesomeItemNotIEvar : itm,
superAwesomeOrderNotIEvar : ord,
superAwesomeXdataNotIEvar : xd,
superAwesomeYdataNotIEvar : yd,
superAwesomeCharHeightNotIEvar : $('.charts-wrapper').height()};
$.ajax({
url: "ajax/data.php",
cache: false,
data: dt,
dataType: "json",
success: function(data) {
// Some fcs
As you can see I already tried renaming all the parameters to something that IE is not likely using for itself (eg the removeFilter story). 如您所见,我已经尝试将所有参数重命名为IE本身无法使用的名称(例如removeFilter故事)。
This is what the function looked like originally 这就是原来的功能
function _getChart(){
$('.series-data').remove();
$.getJSON('ajax/data.php', {
type : window.type,
item : window.item,
order: window.order,
xdata : window.kurtosis,
ydata : window.range,
chartHeight : $('.charts-wrapper').height()}, function(data) {
If I set the dt
array to just {}
it all works, otherwise the error message above is shown. 如果我将
dt
数组设置为{}
那么一切都可以,否则将显示上面的错误消息。
SCRIPT65535: Argument not optionalFile: jquery.js, Line: 4, Column: 13144
SCRIPT65535:参数不是可选文件:jquery.js,行:4,列:13144
jQuery non-min file line where the error appears 出现错误的jQuery非最小文件行
jQuery.param = function( a, traditional ) {
var prefix,
s = [],
add = function( key, value ) {
// If value is a function, invoke it and return its value
value = jQuery.isFunction( value ) ? value() : ( value == null ? "" : value );
s[ s.length ] = encodeURIComponent( key ) + "=" + encodeURIComponent( value );
};
Why? 为什么?
For what it's worth, in my case it was an improperly formed value for 'data'. 就其价值而言,在我看来,这是“数据”的不正确形成的价值。 Try checking dt in a debugger and making sure that it is the right data-type.
尝试在调试器中检查dt并确保它是正确的数据类型。
Add below code in ajax 在ajax中添加以下代码
, cache: false
, processData: false // tell jQuery not to process the data
, contentType: false // tell jQuery not to set contentType
And try it again. 然后再试一次。
$.ajax({
url: "ajax/data.php",
cache: false,
data: dt,
dataType: "json",
cache: false,
processData: false, // tell jQuery not to process the data
contentType: false, // tell jQuery not to set contentType
success: function(data) {
Not sure if this will help, and I know you've already tried $.getJSON, but perhaps this would make IE 11 happier: 不知道这是否会有所帮助,而且我知道您已经尝试过$ .getJSON,但这也许会使IE 11更愉快:
$.post('ajax/data.php', dt, function(data) {
// do something with data
},'json');
Alternately, you could try using $.get instead. 或者,您可以尝试使用$ .get代替。 That is missing the "cache:false" parameter, but I don't believe that's a bad thing.
缺少“ cache:false”参数,但是我不认为这是一件坏事。 Using it doesn't actually mean all browsers will comply.
使用它实际上并不意味着所有浏览器都将遵守。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.