WebMethod内部方法 [英] WebMethod Internal Method
本文介绍了WebMethod内部方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好我试图从jquery调用webmethod但它给我 500内部错误
下面是我的javascript代码和Webmethod
hello i am trying to call a webmethod from a jquery but its giving me 500 Internal Error
Below is my javascript code and Webmethod
function submit() {
var idsInOrder = $("#sortable").sortable("toArray");
console.log(idsInOrder);
var string_arr = idsInOrder.toString();
console.log("STRN-" + string_arr);
var url = "pgArrange.aspx/SaveListOrder";
$.ajax({
type: "POST",
url: url,
contentType: "application/json; charset=utf-8",
dataType: "json",
data: "{'catalogname':'" + string_arr + "'}",
success: function (data) {
}
});
}
[WebMethod]
public static string SaveListOrder(string ids)
{
string id = "";
foreach(string s in ids.Split(','))
{
if (s != "")
{
id = id + s + ",";
}
//int id = ids[i];
//int ordinal = i;
//...
}
return id;
}
推荐答案
( #sortable)。sortable( toArray);
console .log(idsInOrder);
var string_arr = idsInOrder.toString();
console .log( STRN- + string_arr);
var url = pgArrange.aspx / SaveListOrder;
("#sortable").sortable("toArray"); console.log(idsInOrder); var string_arr = idsInOrder.toString(); console.log("STRN-" + string_arr); var url = "pgArrange.aspx/SaveListOrder";
.ajax({
type: POST,
url:url,
contentType: application / json; charset = utf-8,
dataType: json,
数据: {'catalogname':' + string_arr + '},
成功: function (数据){
}
});
}
.ajax({ type: "POST", url: url, contentType: "application/json; charset=utf-8", dataType: "json", data: "{'catalogname':'" + string_arr + "'}", success: function (data) { } }); }
[WebMethod]
public static string SaveListOrder(string ids)
{
string id = "";
foreach(string s in ids.Split(','))
{
if (s != "")
{
id = id + s + ",";
}
//int id = ids[i];
//int ordinal = i;
//...
}
return id;
}
使用Fiddler检查浏览器和服务器之间的流量,因为它经常会显示真实的错误消息。在我的头顶,你传递了一个名为catalogname的参数,但你的方法是期待一个名为ids的参数。参数名称必须匹配。
Use Fiddler to examine the traffic between your browser and server as it often shows you the real error messages. Off the top of my head you are passing a param called catalogname but your method is expecting a param called "ids". The param names have to match.
这篇关于WebMethod内部方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文