当xml数据通过ajax post传递时,webmethod不会调用 [英] webmethod not calling when xml data is passed through ajax post
问题描述
< script type =text / javascript>
函数callcspage()
{
$ .ajax({
类型:POST,
contentType:text / xml,
url:test.aspx / testmethod,
的数据类型: XML,
数据: <形式>< T> RRT< /形式> 中,
// contentType:application / json,
// url:test.aspx / testmethod,
/ / datatype:xml,
//数据:,
成功:函数(数据){
alert(成功) );
},
错误:函数(结果){
alert(error);
}
});
}
callcspage();
< / script>
webmethod in .cs page
[System.Web.Services.WebMethod ]
public static void testmethod()
{
int i = 2;
}
现在我想把这个webmethod称为.cs页面,但它没有调用但是它给成功消息甚至很难它在.cs页面的断点处没有突破
<script type="text/javascript">
function callcspage()
{
$.ajax({
type: "POST",
contentType: "text/xml",
url: "test.aspx/testmethod",
datatype: "xml",
data: "<form><t>rrt</form>",
//contentType: "application/json",
//url: "test.aspx/testmethod",
//datatype: "xml",
//data: "",
success: function (data) {
alert("success");
},
error: function (result) {
alert("error");
}
});
}
callcspage();
</script>
webmethod in .cs page
[System.Web.Services.WebMethod]
public static void testmethod()
{
int i = 2;
}
now i want to call this webmethod which is in .cs page but its not calling but it gives success message even tough it doesnt break at the breakpoint in .cs page
推荐答案
.ajax({
类型:POST,
contentType:text / xml,
URL: Test.aspx文件/ TestMethod的,
的数据类型: XML,
数据:<形式>< T> RRT< / form>,
// contentType:application / json,
// url :test.aspx / testmethod,
//数据类型:xml,
//数据:,
成功:功能(数据){
提醒(成功);
},
错误:功能(结果){
提醒(错误);
}
});
}
callcspage();
< / script>
webmethod in .cs page
[System.Web.Services.WebMethod]
public static void testmethod()
{
int i = 2;
}
现在我想把这个webmethod称为.cs页面,但它没有调用但是它在.cs页面
.ajax({
type: "POST",
contentType: "text/xml",
url: "test.aspx/testmethod",
datatype: "xml",
data: "<form><t>rrt</form>",
//contentType: "application/json",
//url: "test.aspx/testmethod",
//datatype: "xml",
//data: "",
success: function (data) {
alert("success");
},
error: function (result) {
alert("error");
}
});
}
callcspage();
</script>
webmethod in .cs page
[System.Web.Services.WebMethod]
public static void testmethod()
{
int i = 2;
}
now i want to call this webmethod which is in .cs page but its not calling but it gives success message even tough it doesnt break at the breakpoint in .cs page
这篇关于当xml数据通过ajax post传递时,webmethod不会调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!