在浏览器中显示服务错误但在chrome中工作但是在Firefox中没有

时间:2011-11-23 06:39:38

标签: javascript wcf json getjson

当呼叫到达时我有服务方法,它在所有浏览器中显示错误Internet Explorer 8,chrome和firefox 8.0.1。

错误是

OPTIONS http://abc/AddRating 405 (Method Not Allowed)

但是我的服务方法在chrome中执行,即8但不在firefox mozila中执行。 这是firebug网络的回应

Response Headers    view source
Allow   POST
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
Access-Control-Allow-Head...    Origin, Content-Type, Accept
Date    Wed, 23 Nov 2011 06:34:56 GMT


Request Headersview source
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://localhost:7844
Access-Control-Request-Me...    POST
Access-Control-Request-He...    content-type
Pragma  no-cache
Cache-Control   no-cache

这就是我的代码在函数中的样子。

function addService(comments) {
    try {
        // User details
        var user = { "Id": 2007, "FirstName": "Ufone", "LastName": "", "EmailAddress": "ahmed.ali@vidizmo.com509" };
        var ratingInfo = {
            "Id": 0,
            "TenantId": _settings.tenantId,
            "UserId": user.Id,
            "FirstName": user.FirstName,
            "LastName": user.LastName,
            "Rating": 0,
            "EmailAddress": user.EmailAddress,
            "Comments": comments,
            "RatedObjectTypeInfo": { "Id": 2 },
            "RatingTypeInfo": { "Id": 1 },
            "MashupRatingInfo": { "MashupMetaInfoId": _settings.ratedObjectId },
            "RatedObjectId": _settings.ratedObjectId,
            "TotalCount": 0
        };
        // AddRating service Url.
        var url = "http://abc/AddRating";

        $.ajax({
            type: "POST",
            url: url,
            data: JSON.stringify(ratingInfo),
            contentType: "application/json",
            timeout: 5000,
            crossDomain: true,


            success: function (success) {
                if (success == true) {
                    $("#addCommentsTable").hide();

                    var sMsg = document.getElementById('successMsg');
                    sMsg.style.display = "block";
                    // Setting value of a global variable _settings.start to 0 inorder to call the service right from page 1.
                    _settings.start = 0;
                    // Calling Comment displaying Service.
                    service(_settings);
                }
            },
            error: function (xhr, ajaxOptions, thrownError) {
                alert(xhr);
            }
        });
    }
    catch (err) {

        alert(err);
    }

}

请有人可以帮忙?????

1 个答案:

答案 0 :(得分:0)

为了解决这个问题,我现在使用处理程序,我的应用程序在所有浏览器和设备上都能正常运行。