简体   繁体   English

IE 11 Ajax错误-“ SCRIPT65535:参数不可选”

[英]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) {

// Some fcs //一些fcs

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.

相关问题 使用 Internet Explorer 11 发送数据时出现 Ajax 错误 - “SCRIPT65535 参数不是可选的” - Ajax error when sending data with Internet Explorer 11 - “SCRIPT65535 argument not optional” 错误:SCRIPT65535:无效的调用对象行1字符1 - Error: SCRIPT65535: Invalid calling object line 1 character 1 未捕获的TypeError:Chrome或SCRIPT65535中的非法调用:提交表单时IE中的调用对象无效 - Uncaught TypeError: Illegal invocation in Chrome or SCRIPT65535: Invalid calling object in IE when submit form (仅在IE中)SCRIPT65535:对方法或属性访问的意外调用。 main.js,第152行字符28 - (Only in IE) SCRIPT65535: Unexpected call to method or property access. main.js, line 152 character 28 获取错误为 ERROR TypeError: Argument not optional in IE 11 - Getting error as ERROR TypeError: Argument not optional in IE 11 “错误:无效的参数。” 在 IE11 上 - “Error: Invalid argument.” on IE11 IE 11及以下版本中的JavaScript错误“”应为” + AJAX在IE 11中不起作用 - JavaScript error “ ) expected ” in IE 11 & below + AJAX not working in IE 11 IE10 / 11 Ajax XHR错误 - SCRIPT7002:XMLHttpRequest:网络错误0x2ef3 - IE10/11 Ajax XHR error - SCRIPT7002: XMLHttpRequest: Network Error 0x2ef3 Java Script 在 IE11 中出错 - Java Script Gets Error in IE11 IE中的AJAX请求错误,参数无效 - AJAX request error in IE, invalid argument
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM