[英]Passing json object to webmethod via jquery ajax
I am trying to pass a json object to my .net webmethod. 我正在尝试将json对象传递给我的.net网络方法。 Here is my C#:
这是我的C#:
[WebMethod]
public static string Guncelle(string personel)
{
return "It came.";
}
And my jquery ajax: 而我的jQuery Ajax:
var saveData = {};
saveData.Isim = isim;
saveData.Soyad = soyisim;
saveData.Firma = firma;
.
.
.
var result = JSON.stringify({ personel: saveData });
$.ajax({
type: "POST",
url: "Personeller.aspx/Guncelle",
data: result,
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (msg) {
alert(msg.d);
},
error: function (msg) {
alert(msg.d);
}
})
When I run code, it returns 'undefined' with alert. 当我运行代码时,它会返回“未定义”并带有警报。 What is the correct way of passing json object to C# Webmethod ?
将json对象传递给C#Webmethod的正确方法是什么? I tried other examples for passing an object but none of them worked for me.
我尝试了其他传递对象的示例,但没有一个对我有用。
试试这个:data:“ {personel:'” + saveData +“'}”
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.