【发布时间】:2016-08-18 11:17:43
【问题描述】:
我正在尝试将表单发布到我的网络服务,但到目前为止没有取得很大成功。
在发布到服务器之前,我将表单转换为对象。
将表单 Object 发布到我的 Asmx 网络服务时出现错误。
我的阿贾克斯:
var formObject = $(form).serializeObject();
var formData = JSON.stringify(formObject);
$.ajax({
type: "POST",
url: "./Service.asmx/PostAutomaticRule",
data: { myObject: formData },
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (response) {
alert("success");
},
error: function (response) {
alert("Error");
}
});
我的 asmx:
[WebMethod(EnableSession = true)]
public void PostAutomaticRule(MyClass myObject)
{
Debug.WriteLine(myObject);
}
}
[Serializable]
public class MyClass
{
public string automaticRuleName { get; set; }
public string action { get; set; }
public string increaseBudgetByValue { get; set; }
public string increaseBudgetMaximumBudget { get; set; }
}
更多信息: 调试时这些是值:
我做错了什么?
【问题讨论】:
标签: javascript c# ajax web-services