Jquery Ajax方法调用错误

编程入门 行业动态 更新时间:2024-10-27 04:37:37
本文介绍了Jquery Ajax方法调用错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

这是我的Jquery方法

var domain = $(domainId).parent()。find(input [name $ = whoisdomain])VAL(); var params ={domainname:'+ domain +'}; $ .ajax({类型:'POST', url:'.. / SearchResult.aspx / GetResult', contentType:'application / json ; charset = utf-8', data:params, dataType:'json', processData:true,成功:AjaxSucceeded,错误:AjaxFailed }); 服务器端WebMethod Is: [WebMethod] [ScriptMethod(ResponseFormat = ResponseFormat.Json)] public静态列表< 字符串 > GetResult (字符串域名) { //代码在这里}

错误是: {消息:无效的Web服务调用,缺少参数值:\ u0027domainname \ u0027。,StackTrace:at System.Web.Script.Services System.Web上的System.Web.Script.Services.WebServiceMethodData.CallMethodFromRawParams(Object target,IDictionary`2 parameters)\\\\ n中的.WebServiceMethodData.CallMethod(Object target,IDictionary`2参数)\\\\ n .Script.Services.RestHandler.InvokeMethod(HttpContext context,WebServiceMethodData methodData,IDictionary`2 rawPa rams)\\\ at System.Web.Script.Services.RestHandler.ExecuteWebServiceCall(HttpContext context,WebServiceMethodData methodData),ExceptionType:System.InvalidOperationException} Plz告诉我错误在哪里..这个代码在除了Internet Explorer之外的所有浏览器中都能正常工作10

解决方案

(domainId).parent()。find(input [name

= whoisdomain] ).VAL(); var params ={domainname:'+ domain +'};

.ajax({ type:'POST', url:'../SearchResult.aspx/GetResult', contentType:'application / json; charset = utf-8', data:params, dataType:'json', processData:true,成功:AjaxSucceeded,错误:AjaxFailed }); 服务器端WebMethod Is: [WebMethod] [ScriptMethod(ResponseFormat = ResponseFormat.Json)] public静态列表< 字符串 > GetResult (字符串域名) { //代码在这里}

错误是: {消息:无效的Web服务调用,缺少参数值:\ u0027domainname \ u0027。,StackTrace:at System.Web.Script.Services System.Web上的System.Web.Script.Services.WebServiceMethodData.CallMethodFromRawParams(Object target,IDictionary`2 parameters)\\\\ n中的.WebServiceMethodData.CallMethod(Object target,IDictionary`2参数)\\\\ n .Script.Services.RestHandler.InvokeMethod(HttpContext context,WebServiceMethodData methodData,IDictionary`2 rawPa rams)\\\ at System.Web.Script.Services.RestHandler.ExecuteWebServiceCall(HttpContext context,WebServiceMethodData methodData),ExceptionType:System.InvalidOperationException} Plz告诉我错误在哪里..这个代码在除了Internet Explorer之外的所有浏览器中都能正常工作10

This is my Jquery Method

var domain = $(domainId).parent().find("input[name$=whoisdomain]").val(); var params = "{domainname:'" + domain + "'}"; $.ajax({ type: 'POST', url: '../SearchResult.aspx/GetResult', contentType: 'application/json; charset=utf-8', data: params, dataType: 'json', processData:true, success: AjaxSucceeded, error: AjaxFailed }); Server side WebMethod Is: [WebMethod] [ScriptMethod(ResponseFormat = ResponseFormat.Json)] public static List<string> GetResult(string domainname) { //code is here }

ERROR IS: {"Message":"Invalid web service call, missing value for parameter: \u0027domainname\u0027.","StackTrace":" at System.Web.Script.Services.WebServiceMethodData.CallMethod(Object target, IDictionary`2 parameters)\r\n at System.Web.Script.Services.WebServiceMethodData.CallMethodFromRawParams(Object target, IDictionary`2 parameters)\r\n at System.Web.Script.Services.RestHandler.InvokeMethod(HttpContext context, WebServiceMethodData methodData, IDictionary`2 rawParams)\r\n at System.Web.Script.Services.RestHandler.ExecuteWebServiceCall(HttpContext context, WebServiceMethodData methodData)","ExceptionType":"System.InvalidOperationException"} Plz tell me where is the error..this code work fine in all browers except Internet Explorer 10

解决方案

(domainId).parent().find("input[name

=whoisdomain]").val(); var params = "{domainname:'" + domain + "'}";

.ajax({ type: 'POST', url: '../SearchResult.aspx/GetResult', contentType: 'application/json; charset=utf-8', data: params, dataType: 'json', processData:true, success: AjaxSucceeded, error: AjaxFailed }); Server side WebMethod Is: [WebMethod] [ScriptMethod(ResponseFormat = ResponseFormat.Json)] public static List<string> GetResult(string domainname) { //code is here }

ERROR IS: {"Message":"Invalid web service call, missing value for parameter: \u0027domainname\u0027.","StackTrace":" at System.Web.Script.Services.WebServiceMethodData.CallMethod(Object target, IDictionary`2 parameters)\r\n at System.Web.Script.Services.WebServiceMethodData.CallMethodFromRawParams(Object target, IDictionary`2 parameters)\r\n at System.Web.Script.Services.RestHandler.InvokeMethod(HttpContext context, WebServiceMethodData methodData, IDictionary`2 rawParams)\r\n at System.Web.Script.Services.RestHandler.ExecuteWebServiceCall(HttpContext context, WebServiceMethodData methodData)","ExceptionType":"System.InvalidOperationException"} Plz tell me where is the error..this code work fine in all browers except Internet Explorer 10

更多推荐

Jquery Ajax方法调用错误

本文发布于:2023-11-24 19:18:26,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1626491.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:错误   方法   Jquery   Ajax

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!