IE10 not Passing Parameters to a Web Service Method in an AJAX Post Request

社会主义新天地 提交于 2019-12-13 03:59:10

问题


I have a JQuery function that does an AJAX Post on a web service method. This function works well in FireFox, Chrome, Safari and IE 9 and lower. For some strange reason, IE10 does not pass the parameters needed to execute the web method and throws the following exception:

===========================================================================

ExceptionType=System.InvalidOperationException

Message=Invalid web service call, missing value for parameter: 'parameterX'.

StackTrace= at System.Web.Script.Services.WebServiceMethodData.CallMethod(Object target, IDictionary2 parameters) at System.Web.Script.Services.WebServiceMethodData.CallMethodFromRawParams(Object target, IDictionary2 parameters) at System.Web.Script.Services.RestHandler.InvokeMethod(HttpContext context, WebServiceMethodData methodData, IDictionary`2 rawParams) at System.Web.Script.Services.RestHandler.ExecuteWebServiceCall(HttpContext context, WebServiceMethodData methodData)

===========================================================================

I've tried to use all sorts of combinations of passing the data in the AJAX request including the JSON.stringify() method. None worked and this seems like a bug in IE10.

Here is the JQuery function:

    var valueX = $inputBox.val().replace("'", "!");
    var valueY = 1;

    myNameSpace.activeAjaxRequest = $.ajax({
        type: "POST",
        contentType: "application/json; charset=utf-8",
        url: webServiceMethodUrl,
        data: JSON.stringify({ parameterX: valueX, parameterY: valueY }),
        dataType: "json",
        success: function (result) {
           // some code here
        }
        ,
        error: function (sender, textStatus, errorThrown) {
           // some code here
        }
    });

Any fix or workaround is highly appreciated!

来源:https://stackoverflow.com/questions/18758180/ie10-not-passing-parameters-to-a-web-service-method-in-an-ajax-post-request

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!