2

我有一个 js 文件。a 想使用 ajax 将值作为 json 传递给我的代码隐藏,但我收到此错误:消息“:”无效的 Web 服务调用,参数缺少值:\u0027fff\u0027。”,“StackTrace

我的 JavaScript 代码是:

var values = { fff: "tttttttt" };
var uname = "fariddddddd";
  $.ajax({
 type: "GET",
 url: "http://localhost:39787/Default.aspx/dataSave",
 data: JSON.stringify(values),
 contentType: "application/json; charset=utf-8",
 dataType: "json",
 processData: false,
 success: function (msg) {
     AjaxSucceeded(msg);
 },
 error: function (msg) {
     alert(msg);
 }
     });

我背后的代码是:

[WebMethod(true)]
[ScriptMethod(UseHttpGet = true, ResponseFormat = ResponseFormat.Json)]
public static string dataSave(string fff)  
 {
   string a = fff + "kazemi";
   return a;

}

请帮我

4

1 回答 1

1

您没有用引号将密钥括起来。将声明更改为这样。在 javascript 中阅读这个未引用的对象

var values = { "fff": "tttttttt" };
于 2013-01-18T07:37:37.440 回答