简体   繁体   English

在Firefox和IE9中无法获取数据,但在Chrome和Safari中可以正常工作

[英]Can't get data in Firefox and IE9 but it works fine in Chrome and Safari

I have this method 我有这种方法

 function callCommentservice() {
        try {

            // Comment Service Url
         var getCommentServiceUrl = self.commentsServiceUrl + self.getRating + "tenantId=" + self.tenantId + "&ratedObjectTypeId=" + self.ratedObjectTypeId + "&ratedObjectId=" + self.ratedObjectId + "&ratingType=" + self.ratingType + "&start=" + self.start + "&totalRecordsNeeded=" + self.totalRecordsNeeded;


         $.ajax({
     type: "GET",
             url: getCommentServiceUrl,
             contentType: "application/json",
             timeout: 5000,
             beforeSend: function (xhr) {
                 xhr.setRequestHeader("Accept", "application/json");
             },
         dataType: "json",
             success: function (data) {
                 alert("I m in here.............!!!!");

                 //                    if (success == data) {

                 // Assigning totalRecordsNeeded value to global variable pagination_parameters.pageSize
                 pagination_parameters.pageSize = self.totalRecordsNeeded;

                 //Printing on a console.
                 debug("get comments url: " + getCommentServiceUrl);

                 // Calling Service in order to get data.
                 //                        $.getJSON(getCommentServiceUrl + "&callback=?", function (data) {
                 var emptyCommentHyperlink = document.getElementById('emptyCommentHyperlink');
                 // when there is no comment available in a service than this block will work.
                 if (data.length == 0) {

                     emptyCommentHyperlink.style.display = 'block';
                     //emptyCommentHyperlink.onclick = addCommentsBox;
                     $("#emptyCommentHyperlink").click(addCommentsBox);
                 }
                 else {

                     emptyCommentHyperlink.style.display = 'none';
                 }

                 //printing on a console.
                 debug("Date from the get service:" + data);
                 //alert(data);

                 // Changing date format of a service element AddedDateTime.
                 for (var key = 0; key < data.length; key++) {


                     var dataArray = data[key];

                     // Printing on console.
                     debug("data Array after the data object:" + dataArray);
                     var jsonDate = dataArray.AddedDateTime; //AddedDateTime is the service element.'

                     // Printing on a console.
                     debug("converted Time" + jsonDate);

                     var oneSecond = 1000;       // milliseconds in one seconds
                     // changing format of the AddedDateTime
                     var date = new Date(parseInt(jsonDate.substring(6)));

                     var year = date.getFullYear(); // 2011
                     var day = date.getDay();
                     var exactdate = date.getDate();
                     var month = date.getMonth();
                     var hours = date.getHours();
                     var minutes = date.getMinutes();
                     var month_names_short = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];

                     // Fromating Absolute time over tooltip.
                     if (hours > 12) {
                         hours = hours - 12;
                         var exact = zeroPad(hours) + ":" + zeroPad(minutes) + " PM" + ", " + exactdate + " " + month_names_short[month] + " " + year;
                     }
                     else {

                         var exact = zeroPad(hours) + ":" + zeroPad(minutes) + " AM" + ", " + exactdate + " " + month_names_short[month] + " " + year;
                     }

                     // subtracting current date with the comment date.
                     var finalDate = Math.abs(new Date() - date) / oneSecond;

                     dataArray.time_duration = new TimeSpan(finalDate).toString();

                     // Printing on a console.
                     debug("finalDate: " + dataArray.time_duration);

                     //alert(dataArray.time_duration);
                     dataArray.Absolute_Date = exact;

                 }


                 // Extracting TotalCount from service.
                 var totalComments = data[0].TotalCount;
                 // alert(totalComments);


                 //Calling paging Function
                 pages(totalComments);

                 //Making the commenttable empty.
                 $('#commentDiv').empty();

                 // Printing on a console.
                 debug("data before mactache" + data);

                 var comments = { "Comments": data };
                 var html = Mustache.to_html(self.template_html, comments);
                 var target_div = document.getElementById("commentDiv");
                 target_div.innerHTML = html;
                 //alert("target_div");


                 //                        });

             },

             //                },
             error: function (xhr, ajaxOptions, thrownError) {
                 debug(xhr);

                 var errorMsg = document.getElementById('ErrorLable');
                 errorMsg.style.display = "block";
             }
         });
        }

        catch (err) {
            //Printing on a console.
            debug("callCommentservice");
            debug(err);

        }
    }

this method working fine in Chrome and Safari but not working in in IE 9 and firefox , I receive an error 405 in firefox request header is as follows :- 此方法在Chrome和Safari中工作正常,但在IE 9和firefox中不工作,我在firefox请求标头中收到错误405如下:

Response Headers Allow 响应标题允许
GET Content-Length 1565 Content-Type text/html; GET Content-Length 1565 Content-Type text / html; charset=UTF-8 Server Microsoft-IIS/7.5 X-Powered-By ASP.NET Access-Control-Allow-Orig... * Access-Control-Allow-Meth... POST, GET, OPTIONS Access-Control-Allow-Head... CONTENT-TYPE, Accept Access-Control-Max-Age 1728000 Date Wed, 14 Dec 2011 10:30:43 GMT charset = UTF-8服务器Microsoft-IIS / 7.5 X-Powered by ASP.NET Access-Control-Allow-Orig ...... Access-Control-Allow-Meth ... POST,GET,OPTIONS Access-Control-Allow -Head ... CONTENT-TYPE,Accept Access-Control-Max-Age 1728000 Date Wed,14 Dec 2011 10:30:43 GMT

Request Headers Host services.farooq.tv User-Agent Mozilla/5.0 (Windows NT 6.1; WOW64; rv:8.0.1) Gecko/20100101 Firefox/8.0.1 Accept text/html,application/xhtml+xml,application/xml;q=0.9, / ;q=0.8 Accept-Language en-us,en;q=0.5 Accept-Encoding gzip, deflate Accept-Charset ISO-8859-1,utf-8;q=0.7,*;q=0.7 Connection keep-alive Origin http://marketplace.softech-lp35.softech.us Access-Control-Request-Me... GET Access-Control-Request-He... content-type 请求标头主机services.farooq.tv用户代理Mozilla / 5.0(Windows NT 6.1; WOW64; rv:8.0.1)Gecko / 20100101 Firefox / 8.0.1接受text / html,application / xhtml + xml,application / xml; q = 0.9, / ; q = 0.8 Accept-Language zh-cn,en; q = 0.5 Accept-Encoding gzip,deflate接受字符集ISO-8859-1,utf-8; q = 0.7,*; q = 0.7连接keep-alive来源http://marketplace.softech-lp35.softech.us Access-Control-Request-Me ... GET Access-Control-Request-He ...内容类型

contentType中存在一个问题:“ application / json”,我已将其从$ .ajax函数中删除,现在可以正常使用了。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 jquery.ui.tabs.js不会在IE9,Chrome中加载标签数据-在Firefox中工作正常 - jquery.ui.tabs.js doesn't load tab data in IE9, Chrome - works perfectly fine in firefox 无法下载html5以在Firefox中以编程方式工作(适用于Safari,IE,Opera,Chrome) - Can't get html5 download to work programmatically in Firefox(Works on Safari, IE, Opera, Chrome) 在Firefox中输入密钥而不提交数据。在IE和Chrome和Safari中工作正常 - Enter key not submitting data in Firefox..Works fine in IE and Chrome and safari SVG不在Firefox中渲染字体(适用于IE9和Chrome) - SVG doesn't render fonts in Firefox (works in IE9 and Chrome) jQuery模糊在Firefox和Chrome中不起作用,但在IE9中起作用 - Jquery blur doesn't work in Firefox and Chrome but works in IE9 .pause() 在 Chrome 和 Firefox 中不起作用,但在 Safari 中工作正常 - .pause() isn't working in Chrome & Firefox, but works fine in Safari iFrame 在 Chrome 中不起作用(在 FF、IE 和 Safari 中工作正常) - iFrame doesn't work in Chrome (works fine in FF, IE and Safari) 代码在chrome和firefox中有效,但在IE9中失败 - Code works in chrome and firefox but fails in IE9 为什么JS功能在IE9中无法正常工作? 但在Chrome和Firefox中可以正常工作 - Why JS function does not work properly in IE9? but works fine in Chrome and Firefox HighCharts无法在Safari上运行,但在Firefox和Chrome上可以正常运行 - HighCharts not working on Safari but works fine on Firefox and Chrome
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM