简体   繁体   中英

The data is not received by method $.ajax success in ie9

In ie9 the success method receives only by two parameters: textStatus and XMLHttpRequest. Data is always undefined. In all the other the other browsers the code works properly and all the 3 parameters are sent to success method. As a result I cannot process any of the ajax-requests after it is done. What can be the reason for it?

Here is the part of the method code:

SendAjax = function(async, type, act, t, datas)
{
    var datatype = 'html';
    if (type=='reload_weather' || type=='popup' || act == 'set_location')
        datatype = 'json';

    var result = 0;

    $.ajax({
        url: '_ajax/',
        data: {act:act, type:type, datas:datas},
        type: "POST",
        dataType: datatype,
        cache: false,
        async: async,
        success: function(data, textStatus, XMLHttpRequest)
        {
            printArray(arguments);
            /*
             {
                 "1": "success",
                 "2": {
                 "readyState": 4,
                 "status": 200,
                 "statusText": "OK"
                 }
             }
             */

            printArray(data);
            /*
                undefined
             */
        }
    }
}

通过将以下行添加到接收请求的php-file中,可以解决此问题:

header('Content-type: text/html; charset=utf-8');

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM